Search in sources :

Example 11 with SessionId

use of org.apache.activemq.command.SessionId 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 SessionId

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

the class SessionIdTest method createObject.

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

Example 13 with SessionId

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

the class SessionIdTest method populateObject.

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

Example 14 with SessionId

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

the class SessionIdTest method createObject.

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

Example 15 with SessionId

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

the class SessionIdTest method populateObject.

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

Aggregations

SessionId (org.apache.activemq.command.SessionId)23 ConnectionId (org.apache.activemq.command.ConnectionId)3 ConsumerId (org.apache.activemq.command.ConsumerId)3 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)2 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 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 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)1 BrokerId (org.apache.activemq.command.BrokerId)1 BrokerInfo (org.apache.activemq.command.BrokerInfo)1 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)1 DestinationInfo (org.apache.activemq.command.DestinationInfo)1 MessageDispatch (org.apache.activemq.command.MessageDispatch)1 RemoveInfo (org.apache.activemq.command.RemoveInfo)1