use of org.apache.activemq.command.ProducerInfo in project activemq-artemis by apache.
the class OpenWireProtocolManager method fireAdvisory.
/*
* See AdvisoryBroker.fireAdvisory()
*/
public void fireAdvisory(AMQConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId, String originalConnectionId) throws Exception {
if (!this.isSupportAdvisory()) {
return;
}
ActiveMQMessage advisoryMessage = new ActiveMQMessage();
if (originalConnectionId == null) {
originalConnectionId = context.getConnectionId().getValue();
}
advisoryMessage.setStringProperty(MessageUtil.CONNECTION_ID_PROPERTY_NAME.toString(), originalConnectionId);
advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_NAME, getBrokerName());
String id = getBrokerId() != null ? getBrokerId().getValue() : "NOT_SET";
advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_ID, id);
String url = context.getConnection().getLocalAddress();
advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_ORIGIN_BROKER_URL, url);
// set the data structure
advisoryMessage.setDataStructure(command);
advisoryMessage.setPersistent(false);
advisoryMessage.setType(AdvisorySupport.ADIVSORY_MESSAGE_TYPE);
advisoryMessage.setMessageId(new MessageId(advisoryProducerId, messageIdGenerator.getNextSequenceId()));
advisoryMessage.setTargetConsumerId(targetConsumerId);
advisoryMessage.setDestination(topic);
advisoryMessage.setResponseRequired(false);
advisoryMessage.setProducerId(advisoryProducerId);
boolean originalFlowControl = context.isProducerFlowControl();
final AMQProducerBrokerExchange producerExchange = new AMQProducerBrokerExchange();
producerExchange.setConnectionContext(context);
producerExchange.setProducerState(new ProducerState(new ProducerInfo()));
try {
context.setProducerFlowControl(false);
AMQSession sess = context.getConnection().getAdvisorySession();
if (sess != null) {
sess.send(producerExchange.getProducerState().getInfo(), advisoryMessage, false);
}
} finally {
context.setProducerFlowControl(originalFlowControl);
}
}
use of org.apache.activemq.command.ProducerInfo in project activemq-artemis by apache.
the class ProducerInfoTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ProducerInfo info = (ProducerInfo) object;
info.setProducerId(createProducerId("ProducerId:1"));
info.setDestination(createActiveMQDestination("Destination:2"));
{
BrokerId[] value = new BrokerId[2];
for (int i = 0; i < 2; i++) {
value[i] = createBrokerId("BrokerPath:3");
}
info.setBrokerPath(value);
}
info.setDispatchAsync(true);
info.setWindowSize(1);
}
use of org.apache.activemq.command.ProducerInfo in project activemq-artemis by apache.
the class ProducerInfoTest method createObject.
@Override
public Object createObject() throws Exception {
ProducerInfo info = new ProducerInfo();
populateObject(info);
return info;
}
use of org.apache.activemq.command.ProducerInfo in project activemq-artemis by apache.
the class ProducerInfoTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
ProducerInfo info = (ProducerInfo) object;
info.setProducerId(createProducerId("ProducerId:1"));
info.setDestination(createActiveMQDestination("Destination:2"));
{
BrokerId[] value = new BrokerId[2];
for (int i = 0; i < 2; i++) {
value[i] = createBrokerId("BrokerPath:3");
}
info.setBrokerPath(value);
}
info.setDispatchAsync(true);
info.setWindowSize(1);
}
use of org.apache.activemq.command.ProducerInfo in project activemq-artemis by apache.
the class ProducerInfoTest method createObject.
@Override
public Object createObject() throws Exception {
ProducerInfo info = new ProducerInfo();
populateObject(info);
return info;
}
Aggregations