- final Object response = process(query, message);
-
- new Thread() {
- public void run() {
- // Send response
- jmsTemplate.convertAndSend(responseDestination, response,
- new MessagePostProcessor() {
- public Message postProcessMessage(
- Message messageToSend) throws JMSException {
- messageToSend
- .setStringProperty(
- PROPERTY_QUERY,
- message
- .getStringProperty(PROPERTY_QUERY));
- messageToSend.setStringProperty(
- PROPERTY_SLC_AGENT_ID, agentDescriptor
- .getUuid());
- messageToSend.setJMSCorrelationID(message
- .getJMSCorrelationID());
- return messageToSend;
- }
- });
- if (log.isDebugEnabled())
- log.debug("Sent response to query " + query
- + " with correlationId " + correlationId);
+ final Object response;
+ final Destination destinationSend;
+ if (QUERY_PING_ALL.equals(query)) {
+ ReferenceList refList = (ReferenceList) convertFrom(message);
+ if (!refList.getReferences().contains(agentDescriptor.getUuid())) {
+ response = agentDescriptor;
+ destinationSend = agentRegister;
+ log.info("Agent #" + agentDescriptor.getUuid()
+ + " registering to " + agentRegister
+ + " in reply to a " + QUERY_PING_ALL + " query");
+ } else {
+ return;