Skip to content

Commit

Permalink
Merge branch '1.12.x' into 1.13.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Jan 10, 2025
2 parents 557b611 + be6f962 commit 819fa61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.micrometer.jakarta9.instrument.jms;

import io.micrometer.common.util.internal.logging.WarnThenDebugLogger;
import io.micrometer.observation.transport.ReceiverContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;

/**
Expand All @@ -33,12 +33,16 @@
*/
public class JmsProcessObservationContext extends ReceiverContext<Message> {

private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsProcessObservationContext.class);

public JmsProcessObservationContext(Message receivedMessage) {
super((message, key) -> {
try {
return message.getStringProperty(key);
}
catch (JMSException exc) {
// Some JMS providers throw exceptions other than JMSException
catch (Exception exc) {
logger.log("Failed to get message property.", exc);
return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package io.micrometer.jakarta9.instrument.jms;

import io.micrometer.common.lang.Nullable;
import io.micrometer.common.util.internal.logging.WarnThenDebugLogger;
import io.micrometer.observation.transport.SenderContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;

/**
Expand All @@ -33,15 +33,18 @@
*/
public class JmsPublishObservationContext extends SenderContext<Message> {

private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsPublishObservationContext.class);

public JmsPublishObservationContext(@Nullable Message sendMessage) {
super((message, key, value) -> {
try {
if (message != null) {
if (message != null) {
try {
message.setStringProperty(key, value);
}
}
catch (JMSException exc) {
// ignore
// Some JMS providers throw exceptions other than JMSException
catch (Exception exc) {
logger.log("Failed to set message property.", exc);
}
}
});
setCarrier(sendMessage);
Expand Down

0 comments on commit 819fa61

Please sign in to comment.