File tree 2 files changed +15
-8
lines changed
micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms
2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package io .micrometer .jakarta9 .instrument .jms ;
18
18
19
+ import io .micrometer .common .util .internal .logging .WarnThenDebugLogger ;
19
20
import io .micrometer .observation .transport .ReceiverContext ;
20
- import jakarta .jms .JMSException ;
21
21
import jakarta .jms .Message ;
22
22
23
23
/**
33
33
*/
34
34
public class JmsProcessObservationContext extends ReceiverContext <Message > {
35
35
36
+ private static final WarnThenDebugLogger logger = new WarnThenDebugLogger (JmsProcessObservationContext .class );
37
+
36
38
public JmsProcessObservationContext (Message receivedMessage ) {
37
39
super ((message , key ) -> {
38
40
try {
39
41
return message .getStringProperty (key );
40
42
}
41
- catch (JMSException exc ) {
43
+ // Some JMS providers throw exceptions other than JMSException
44
+ catch (Exception exc ) {
45
+ logger .log ("Failed to get message property." , exc );
42
46
return null ;
43
47
}
44
48
});
Original file line number Diff line number Diff line change 17
17
package io .micrometer .jakarta9 .instrument .jms ;
18
18
19
19
import io .micrometer .common .lang .Nullable ;
20
+ import io .micrometer .common .util .internal .logging .WarnThenDebugLogger ;
20
21
import io .micrometer .observation .transport .SenderContext ;
21
- import jakarta .jms .JMSException ;
22
22
import jakarta .jms .Message ;
23
23
24
24
/**
33
33
*/
34
34
public class JmsPublishObservationContext extends SenderContext <Message > {
35
35
36
+ private static final WarnThenDebugLogger logger = new WarnThenDebugLogger (JmsPublishObservationContext .class );
37
+
36
38
public JmsPublishObservationContext (@ Nullable Message sendMessage ) {
37
39
super ((message , key , value ) -> {
38
- try {
39
- if ( message != null ) {
40
+ if ( message != null ) {
41
+ try {
40
42
message .setStringProperty (key , value );
41
43
}
42
- }
43
- catch (JMSException exc ) {
44
- // ignore
44
+ // Some JMS providers throw exceptions other than JMSException
45
+ catch (Exception exc ) {
46
+ logger .log ("Failed to set message property." , exc );
47
+ }
45
48
}
46
49
});
47
50
setCarrier (sendMessage );
You can’t perform that action at this time.
0 commit comments