Reputation: 2215
I already posted a question on this topic some two days earlier, but it was much more complicated question. Now, to put it more simply:
Is there a way to obtain username, used to connect the broker, in spring JMS listener? I have found only MessageListener and SessionAwareMessageListener, but I'm not able to obtain this information (or Connection instnace) from neither Session, nor Message instance.
Am I missing something obvious?
I'm using ActiveMQ embedded broker.
Upvotes: 0
Views: 591
Reputation: 607
How about?
@JmsListener(destination = "mytopic")
public void processMessage(BytesMessage message) {
ActiveMQBytesMessage msg = (ActiveMQBytesMessage) message;
ActiveMQConnection conn = msg.getConnection();
ConnectionInfo info = conn.getConnectionInfo();
String username = info.getUserName();
}
Upvotes: 0
Reputation: 2215
OK, the obvious answer was, that the connection listener is on is not the same connection as the client is on... Therefore, there is NO POINT of obtaining the connection handle...
Stupid me...
PS: I'm leaving it here to warn the future generations.
Upvotes: 2