Guest User

Untitled

a guest
May 2nd, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1.     public void fireAdvisory(ConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId, ActiveMQMessage advisoryMessage) throws Exception {
  2.         if (getBrokerService().isStarted()) {
  3.             //set properties
  4.             advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_NAME, getBrokerName());
  5.             String id = getBrokerId() != null ? getBrokerId().getValue() : "NOT_SET";
  6.             advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID, id);
  7.  
  8.             String url = getBrokerService().getVmConnectorURI().toString();
  9.             if (getBrokerService().getDefaultSocketURIString() != null) {
  10.                 url = getBrokerService().getDefaultSocketURIString();
  11.             }
  12.             advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL, url);
  13.  
  14.             //set the data structure
  15.             advisoryMessage.setDataStructure(command);
  16.             advisoryMessage.setPersistent(false);
  17.             advisoryMessage.setType(AdvisorySupport.ADIVSORY_MESSAGE_TYPE);
  18.             advisoryMessage.setMessageId(new MessageId(advisoryProducerId, messageIdGenerator.getNextSequenceId()));
  19.             advisoryMessage.setTargetConsumerId(targetConsumerId);
  20.             advisoryMessage.setDestination(topic);
  21.             advisoryMessage.setResponseRequired(false);
  22.             advisoryMessage.setProducerId(advisoryProducerId);
  23.             boolean originalFlowControl = context.isProducerFlowControl();
  24.             final ProducerBrokerExchange producerExchange = new ProducerBrokerExchange();
  25.             producerExchange.setConnectionContext(context);
  26.             producerExchange.setMutable(true);
  27.             producerExchange.setProducerState(new ProducerState(new ProducerInfo()));
  28.             try {
  29.                 context.setProducerFlowControl(false);
  30.                 next.send(producerExchange, advisoryMessage);
  31.             } finally {
  32.                 context.setProducerFlowControl(originalFlowControl);
  33.             }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment