Radhwen
Radhwen

Reputation: 232

getting the DefaultMessageListenerContainer from within the listener

I have the following configuration :

<jms:listener-container container-type="default" connection-factory="cachedConnectionFactory" acknowledge="auto">
     <jms:listener id="myListenerContainerId" destination="myDestination" ref="myListener" method="onMessage" />
</jms:listener-container>

<bean id="myListenerId" class="X.Y.Z.myListener">
    // Some attributes
</bean>

And the following listener :

public class myListener implements MessageListener {

@Override
public void onMessage(Message message) {
    // Some work
    } 
}

Is there a way to get the DefaultMessageListenerContainer myListenerContainerId from within my listener ?

To clarify my needs, the listener onMessage is getting triggered whether myListenerId is running or not, active or not. I need to check if it's triggered only from myListenerContainerId.

Upvotes: 1

Views: 567

Answers (1)

Gary Russell
Gary Russell

Reputation: 174544

No; but if you add new RuntimeException().printStackTrace() you can see where it is called from.

Or you could examine the thread name (which has DefaultMessageListenerContainer in it, by default).

Upvotes: 2

Related Questions