Search in sources :

Example 81 with ProducerInfo

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);
    }
}
Also used : AMQSession(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession) ProducerInfo(org.apache.activemq.command.ProducerInfo) ProducerState(org.apache.activemq.state.ProducerState) AMQProducerBrokerExchange(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) MessageId(org.apache.activemq.command.MessageId)

Example 82 with ProducerInfo

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);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo)

Example 83 with ProducerInfo

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;
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo)

Example 84 with ProducerInfo

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);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo)

Example 85 with ProducerInfo

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;
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo)

Aggregations

ProducerInfo (org.apache.activemq.command.ProducerInfo)95 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)72 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)72 SessionInfo (org.apache.activemq.command.SessionInfo)72 Message (org.apache.activemq.command.Message)69 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)42 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)18 XATransactionId (org.apache.activemq.command.XATransactionId)15 StubConnection (org.apache.activemq.broker.StubConnection)14 MessageAck (org.apache.activemq.command.MessageAck)14 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)11 DataArrayResponse (org.apache.activemq.command.DataArrayResponse)9 TransactionInfo (org.apache.activemq.command.TransactionInfo)9 LocalTransactionId (org.apache.activemq.command.LocalTransactionId)8 Response (org.apache.activemq.command.Response)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)4 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)4 TransactionId (org.apache.activemq.command.TransactionId)4