Search in sources :

Example 1 with AMQProducerBrokerExchange

use of org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange in project activemq-artemis by apache.

the class OpenWireConnection method getProducerBrokerExchange.

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

Example 2 with AMQProducerBrokerExchange

use of org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange 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)

Aggregations

AMQProducerBrokerExchange (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange)2 ProducerInfo (org.apache.activemq.command.ProducerInfo)2 ProducerState (org.apache.activemq.state.ProducerState)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AMQSession (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession)1 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)1 MessageId (org.apache.activemq.command.MessageId)1 SessionState (org.apache.activemq.state.SessionState)1