Search in sources :

Example 11 with ConnectionId

use of org.apache.activemq.command.ConnectionId in project activemq-artemis by apache.

the class OpenWireConnection method addConsumer.

public void addConsumer(ConsumerInfo info) throws Exception {
    // Todo: add a destination interceptors holder here (amq supports this)
    SessionId sessionId = info.getConsumerId().getParentId();
    ConnectionId connectionId = sessionId.getParentId();
    ConnectionState cs = getState();
    if (cs == null) {
        throw new IllegalStateException("Cannot add a consumer to a connection that had not been registered: " + connectionId);
    }
    SessionState ss = cs.getSessionState(sessionId);
    if (ss == null) {
        throw new IllegalStateException(server + " Cannot add a consumer to a session that had not been registered: " + sessionId);
    }
    // Avoid replaying dup commands
    if (!ss.getConsumerIds().contains(info.getConsumerId())) {
        AMQSession amqSession = sessions.get(sessionId);
        if (amqSession == null) {
            throw new IllegalStateException("Session not exist! : " + sessionId);
        }
        List<AMQConsumer> consumersList = amqSession.createConsumer(info, new SlowConsumerDetection());
        if (consumersList.size() == 0) {
            return;
        }
        this.addConsumerBrokerExchange(info.getConsumerId(), amqSession, consumersList);
        ss.addConsumer(info);
        amqSession.start();
        if (AdvisorySupport.isAdvisoryTopic(info.getDestination())) {
            // advisory for temp destinations
            if (AdvisorySupport.isTempDestinationAdvisoryTopic(info.getDestination())) {
                // Replay the temporary destinations.
                List<DestinationInfo> tmpDests = this.protocolManager.getTemporaryDestinations();
                for (DestinationInfo di : tmpDests) {
                    ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(di.getDestination());
                    String originalConnectionId = di.getConnectionId().getValue();
                    protocolManager.fireAdvisory(context, topic, di, info.getConsumerId(), originalConnectionId);
                }
            }
        }
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) SessionState(org.apache.activemq.state.SessionState) DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) AMQConsumer(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConnectionId(org.apache.activemq.command.ConnectionId) AMQSession(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession) ConnectionState(org.apache.activemq.state.ConnectionState) SessionId(org.apache.activemq.command.SessionId)

Example 12 with ConnectionId

use of org.apache.activemq.command.ConnectionId in project activemq-artemis by apache.

the class ConnectionIdTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ConnectionId info = (ConnectionId) object;
    info.setValue("Value:1");
}
Also used : ConnectionId(org.apache.activemq.command.ConnectionId)

Example 13 with ConnectionId

use of org.apache.activemq.command.ConnectionId in project activemq-artemis by apache.

the class ConnectionIdTest method createObject.

@Override
public Object createObject() throws Exception {
    ConnectionId info = new ConnectionId();
    populateObject(info);
    return info;
}
Also used : ConnectionId(org.apache.activemq.command.ConnectionId)

Example 14 with ConnectionId

use of org.apache.activemq.command.ConnectionId in project activemq-artemis by apache.

the class ConnectionIdTest method createObject.

@Override
public Object createObject() throws Exception {
    ConnectionId info = new ConnectionId();
    populateObject(info);
    return info;
}
Also used : ConnectionId(org.apache.activemq.command.ConnectionId)

Example 15 with ConnectionId

use of org.apache.activemq.command.ConnectionId in project activemq-artemis by apache.

the class ConnectionIdTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ConnectionId info = (ConnectionId) object;
    info.setValue("Value:1");
}
Also used : ConnectionId(org.apache.activemq.command.ConnectionId)

Aggregations

ConnectionId (org.apache.activemq.command.ConnectionId)30 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)7 RemoveInfo (org.apache.activemq.command.RemoveInfo)3 SessionId (org.apache.activemq.command.SessionId)3 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)2 ConsumerId (org.apache.activemq.command.ConsumerId)2 MessageAck (org.apache.activemq.command.MessageAck)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 IllegalStateException (javax.jms.IllegalStateException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 AMQConsumer (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConsumer)1 AMQSession (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession)1 BrokerService (org.apache.activemq.broker.BrokerService)1 ConnectionContext (org.apache.activemq.broker.ConnectionContext)1 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)1 ActiveMQTempQueue (org.apache.activemq.command.ActiveMQTempQueue)1 BrokerId (org.apache.activemq.command.BrokerId)1 BrokerInfo (org.apache.activemq.command.BrokerInfo)1 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)1