broadcastConsumer.setMessageListener(new MessageListener() {
public void onMessage(Message message) {
try {
Object obj = ((ObjectMessage) message).getObject();
if (obj instanceof EndpointEvent) {
EndpointEvent event = (EndpointEvent) obj;
String container = ((InternalEndpoint) event.getEndpoint()).getComponentNameSpace().getContainerName();
if (!getBroker().getContainer().getName().equals(container)) {
if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_REGISTERED) {
onRemoteEndpointRegistered(event);
} else if (event.getEventType() == EndpointEvent.INTERNAL_ENDPOINT_UNREGISTERED) {
onRemoteEndpointUnregistered(event);
}
}
}
} catch (Exception e) {
log.error("Error processing incoming broadcast message", e);
}
}
});
Topic advisoryTopic = AdvisorySupport.getConsumerAdvisoryTopic((ActiveMQDestination) broadcastTopic);
advisoryConsumer = broadcastSession.createConsumer(advisoryTopic);
advisoryConsumer.setMessageListener(new MessageListener() {
public void onMessage(Message message) {
if (started.get()) {
onAdvisoryMessage(((ActiveMQMessage) message).getDataStructure());
}
}
});
// Start queue consumers for all components
for (Iterator it = broker.getContainer().getRegistry().getComponents().iterator(); it.hasNext();) {
ComponentMBeanImpl cmp = (ComponentMBeanImpl) it.next();
if (cmp.isStarted()) {
onComponentStarted(new ComponentEvent(cmp, ComponentEvent.COMPONENT_STARTED));
}
}
// Start queue consumers for all endpoints
ServiceEndpoint[] endpoints = broker.getContainer().getRegistry().getEndpointsForInterface(null);
for (int i = 0; i < endpoints.length; i++) {
if (endpoints[i] instanceof InternalEndpoint && ((InternalEndpoint) endpoints[i]).isLocal()) {
onInternalEndpointRegistered(new EndpointEvent(endpoints[i],
EndpointEvent.INTERNAL_ENDPOINT_REGISTERED), false);
}
}
} catch (JMSException e) {
JBIException jbiEx = new JBIException("JMSException caught in start: " + e.getMessage());