public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage) message; Object command = activeMessage.getDataStructure(); if (command instanceof DestinationInfo) { DestinationInfo destinationInfo = (DestinationInfo) command; DestinationEvent event = new DestinationEvent(this, destinationInfo); fireDestinationEvent(event); } else { LOG.warn("Unknown dataStructure: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ConsumerInfo) { count = consumerCount.incrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isConsumerRemove()) { count = consumerCount.decrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
final ActiveMQMessage message = (ActiveMQMessage) command; if (NetworkBridgeFilter.isAdvisoryInterpretedByNetworkBridge(message)) { serviceRemoteConsumerAdvisory(message.getDataStructure()); ackAdvisory(message); } else {
//org.apache.activemq.advisory.AdvisorySupport.getDestinationAdvisoryTopic(Destination) Destination advisoryDestination = AdvisorySupport.getConsumerAdvisoryTopic(topic ) MessageConsumer consumer = session.createConsumer(advisoryDestination); consumer.setMessageListener(this); public void onMessage(Message msg){ if (msg instanceof ActiveMQMessage){ try { ActiveMQMessage aMsg = (ActiveMQMessage)msg; ConsumerInfo consumer = (ConsumerInfo) aMsg.getDataStructure(); } catch (JMSException e) { log.error("Failed to process message: " + msg); } } }
public void onMessage(Message message) { if (started.get()) { onAdvisoryMessage(((ActiveMQMessage) message).getDataStructure()); } } };
protected void displayAdvisoryMessage(ActiveMQMessage cmdMsg) throws IOException, JMSException { final String topic = cmdMsg.getJMSDestination().toString(); final String advisoryMsg = advisoryDataStructureToString(cmdMsg.getDataStructure()); final String advisoryType = cmdMsg.getDataStructure() != null ? "Type: " + dataStructureTypeToString(cmdMsg.getDataStructure().getDataStructureType()) : ""; output("Advisory on " + topic + advisoryType + (advisoryMsg != null ? " Info " + advisoryMsg : "")); }
@Override public void registerQueueStateListener(String queueName, Consumer<QueueState> queueStateChanged) { try { Destination dest = session.createTopic("ActiveMQ.Advisory.Consumer.Queue." + queueName); MessageConsumer consumer = session.createConsumer(dest); consumer.setMessageListener((Message msg) -> { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; if (aMsg.getDataStructure() instanceof ConsumerInfo) { threadPool.submit(() -> queueStateChanged.accept(IAdvisory.QueueState.OPEN)); } if (aMsg.getDataStructure() instanceof RemoveInfo) { threadPool.submit(() -> queueStateChanged.accept(IAdvisory.QueueState.CLOSE)); } } }); advisoryConsumers.put(queueName, consumer); } catch (JMSException e) { System.err.println("Error processing Advisory Message: " + e); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage) message; Object command = activeMessage.getDataStructure(); if (command instanceof DestinationInfo) { DestinationInfo destinationInfo = (DestinationInfo) command; DestinationEvent event = new DestinationEvent(this, destinationInfo); fireDestinationEvent(event); } else { LOG.warn("Unknown dataStructure: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage) message; Object command = activeMessage.getDataStructure(); if (command instanceof DestinationInfo) { DestinationInfo destinationInfo = (DestinationInfo) command; DestinationEvent event = new DestinationEvent(this, destinationInfo); fireDestinationEvent(event); } else { LOG.warn("Unknown dataStructure: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
@Override public void onMessage(Message msg) { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; // if (aMsg.getDataStructure() instanceof // ConnectionInfo) { // ConnectionInfo info = (ConnectionInfo) // aMsg.getDataStructure(); // System.out.println("Connection Info: " + info); // } if (aMsg.getDataStructure() instanceof RemoveInfo) { RemoveInfo info = (RemoveInfo) aMsg.getDataStructure(); // System.out.println("Remove Info: " + info); ConnectionId connectionId = (ConnectionId) info.getObjectId(); clientDisconnected.accept(trimConnectionId(connectionId.getValue())); } } } });
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage) message; Object command = activeMessage.getDataStructure(); if (command instanceof DestinationInfo) { DestinationInfo destinationInfo = (DestinationInfo) command; DestinationEvent event = new DestinationEvent(this, destinationInfo); fireDestinationEvent(event); } else { LOG.warn("Unknown dataStructure: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage) message; Object command = activeMessage.getDataStructure(); if (command instanceof DestinationInfo) { DestinationInfo destinationInfo = (DestinationInfo) command; DestinationEvent event = new DestinationEvent(this, destinationInfo); fireDestinationEvent(event); } else { LOG.warn("Unknown dataStructure: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
Destination advisoryDestination = AdvisorySupport.getExpiredQueueMessageAdvisoryTopic(destination) MessageConsumer consumer = session.createConsumer(advisoryDestination); consumer.setMessageListener(this); public void onMessage(Message msg){ String messageId = msg.getJMSMessageID(); String orignalMessageId = msg.getStringProperty(org.apache.activemq.advisory.AdvisorySupport.MSG_PROPERTY_MESSAGE_ID); if (msg instanceof ActiveMQMessage){ try { ActiveMQMessage aMsg = (ActiveMQMessage)msg; ProducerInfo prod = (ProducerInfo) aMsg.getDataStructure(); } catch (JMSException e) { log.error("Failed to process message: " + msg); } } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ConsumerInfo) { count = consumerCount.incrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isConsumerRemove()) { count = consumerCount.decrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
/** * Listener on the ActiveMQ advisory topic so we get messages when a cluster * node is added or removed */ protected void onConsumerMonitorMessage(Message advisoryMessage) { if (!started.get()) { return; } Object obj = ((ActiveMQMessage) advisoryMessage).getDataStructure(); if (obj instanceof ConsumerInfo) { ConsumerInfo info = (ConsumerInfo) obj; addClusterNode(info.getConsumerId().getConnectionId()); } else if (obj instanceof RemoveInfo) { ConsumerId consumerId = (ConsumerId) ((RemoveInfo) obj).getObjectId(); removeClusterNode(consumerId.getConnectionId()); } }
@Override public String getTimestampFieldValue() { if (hasEventBody() && !hasTimestampProperty()) { Message jmsMessage = getEventBody(); if (jmsMessage instanceof ActiveMQMessage) { ActiveMQMessage advisoryMessage = (ActiveMQMessage) jmsMessage; DataStructure dataStructure = advisoryMessage.getDataStructure(); if (dataStructure instanceof ActiveMQMessage) { ActiveMQMessage advisedMessage = (ActiveMQMessage) dataStructure; long timestampMillis = advisedMessage.getBrokerOutTime(); if (timestampMillis <= 0) { timestampMillis = advisedMessage.getBrokerInTime(); } if (timestampMillis > 0) { String timestampString = String.valueOf(timestampMillis); return timestampString; } } } } return super.getTimestampFieldValue(); }