org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange

Here are the examples of the java api class org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange taken from open source projects.

1. OpenWireProtocolManager#fireAdvisory()

Project: activemq-artemis
File: OpenWireProtocolManager.java
/*
    * See AdvisoryBroker.fireAdvisory()
    */
public void fireAdvisory(AMQConnectionContext context, ActiveMQTopic topic, Command command, ConsumerId targetConsumerId) throws Exception {
    ActiveMQMessage advisoryMessage = new ActiveMQMessage();
    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);
    }
}

2. OpenWireConnection#getProducerBrokerExchange()

Project: activemq-artemis
File: OpenWireConnection.java
private AMQProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException {
    AMQProducerBrokerExchange result = producerExchanges.get(id);
    if (result == null) {
        synchronized (producerExchanges) {
            result = new AMQProducerBrokerExchange();
            result.setConnectionContext(context);
            //todo: this used to check for  && this.acceptorUsed.isAuditNetworkProducers()
            if (context.isReconnect() || (context.isNetworkConnection())) {
                // once implemented ARTEMIS-194, we need to set the storedSequenceID here somehow
                // We have different semantics on Artemis Journal, but we could adapt something for this
                // TBD during the implemetnation of ARTEMIS-194
                result.setLastStoredSequenceId(0);
            }
            SessionState ss = state.getSessionState(id.getParentId());
            if (ss != null) {
                result.setProducerState(ss.getProducerState(id));
                ProducerState producerState = ss.getProducerState(id);
                if (producerState != null && producerState.getInfo() != null) {
                    ProducerInfo info = producerState.getInfo();
                }
            }
            producerExchanges.put(id, result);
        }
    }
    return result;
}