Search in sources :

Example 11 with DestinationInfo

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

the class BrokerNetworkWithStuckMessagesTest method createTempDestinationInfo.

protected DestinationInfo createTempDestinationInfo(ConnectionInfo connectionInfo, byte destinationType) {
    DestinationInfo info = new DestinationInfo();
    info.setConnectionId(connectionInfo.getConnectionId());
    info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE);
    info.setDestination(ActiveMQDestination.createDestination(info.getConnectionId() + ":" + (++tempDestGenerator), destinationType));
    return info;
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Example 12 with DestinationInfo

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

the class BrokerTestSupport method createDestinationInfo.

protected ActiveMQDestination createDestinationInfo(StubConnection connection, ConnectionInfo connectionInfo1, byte destinationType) throws Exception {
    if ((destinationType & ActiveMQDestination.TEMP_MASK) != 0) {
        DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType);
        connection.send(info);
        return info.getDestination();
    } else {
        return ActiveMQDestination.createDestination(queueName, destinationType);
    }
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Example 13 with DestinationInfo

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

the class BrokerTestSupport method createTempDestinationInfo.

protected DestinationInfo createTempDestinationInfo(ConnectionInfo connectionInfo, byte destinationType) {
    DestinationInfo info = new DestinationInfo();
    info.setConnectionId(connectionInfo.getConnectionId());
    info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE);
    info.setDestination(ActiveMQDestination.createDestination(info.getConnectionId() + ":" + (++tempDestGenerator), destinationType));
    return info;
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo)

Example 14 with DestinationInfo

use of org.apache.activemq.command.DestinationInfo 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 15 with DestinationInfo

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

the class OpenWireConnection method tempQueueDeleted.

@Override
public void tempQueueDeleted(SimpleString bindingName) {
    ActiveMQDestination dest = new ActiveMQTempQueue(bindingName.toString());
    state.removeTempDestination(dest);
    if (!AdvisorySupport.isAdvisoryTopic(dest)) {
        AMQConnectionContext context = getContext();
        DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
        ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
        try {
            protocolManager.fireAdvisory(context, topic, advInfo);
        } catch (Exception e) {
            logger.warn("Failed to fire advisory on " + topic, e);
        }
    }
}
Also used : DestinationInfo(org.apache.activemq.command.DestinationInfo) ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) AMQConnectionContext(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQRemoteDisconnectException(org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException) IllegalStateException(javax.jms.IllegalStateException) XAException(javax.transaction.xa.XAException) InvalidDestinationException(javax.jms.InvalidDestinationException) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) IOException(java.io.IOException) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) JMSSecurityException(javax.jms.JMSSecurityException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) InvalidClientIDException(javax.jms.InvalidClientIDException) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

DestinationInfo (org.apache.activemq.command.DestinationInfo)27 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)4 IllegalStateException (javax.jms.IllegalStateException)3 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)3 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 AMQConnectionContext (org.apache.activemq.artemis.core.protocol.openwire.amq.AMQConnectionContext)3 IOException (java.io.IOException)2 InvalidClientIDException (javax.jms.InvalidClientIDException)2 InvalidDestinationException (javax.jms.InvalidDestinationException)2 JMSSecurityException (javax.jms.JMSSecurityException)2 XAException (javax.transaction.xa.XAException)2 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)2 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)2 ActiveMQRemoteDisconnectException (org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException)2 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)2 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)2 ActiveMQTempQueue (org.apache.activemq.command.ActiveMQTempQueue)2 Connection (javax.jms.Connection)1 Destination (javax.jms.Destination)1