Search in sources :

Example 6 with RemotingConnection

use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method listRemoteAddresses.

@Override
public String[] listRemoteAddresses(final String ipAddress) {
    checkStarted();
    clearIO();
    try {
        Set<RemotingConnection> connections = remotingService.getConnections();
        List<String> remoteConnections = new ArrayList<>();
        for (RemotingConnection connection : connections) {
            String remoteAddress = connection.getRemoteAddress();
            if (remoteAddress.contains(ipAddress)) {
                remoteConnections.add(connection.getRemoteAddress());
            }
        }
        return remoteConnections.toArray(new String[remoteConnections.size()]);
    } finally {
        blockOnIO();
    }
}
Also used : RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 7 with RemotingConnection

use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method listRemoteAddresses.

@Override
public String[] listRemoteAddresses() {
    checkStarted();
    clearIO();
    try {
        Set<RemotingConnection> connections = remotingService.getConnections();
        String[] remoteAddresses = new String[connections.size()];
        int i = 0;
        for (RemotingConnection connection : connections) {
            remoteAddresses[i++] = connection.getRemoteAddress();
        }
        return remoteAddresses;
    } finally {
        blockOnIO();
    }
}
Also used : RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 8 with RemotingConnection

use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.

the class ActiveMQServerControlImpl method closeConnectionWithID.

@Override
public boolean closeConnectionWithID(final String ID) {
    checkStarted();
    clearIO();
    try {
        for (RemotingConnection connection : remotingService.getConnections()) {
            if (connection.getID().toString().equals(ID)) {
                remotingService.removeConnection(connection.getID());
                connection.fail(ActiveMQMessageBundle.BUNDLE.connectionWithIDClosedByManagement(ID));
                return true;
            }
        }
    } finally {
        blockOnIO();
    }
    return false;
}
Also used : RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)

Example 9 with RemotingConnection

use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.

the class AddressControlImpl method sendMessage.

@Override
public String sendMessage(final Map<String, String> headers, final int type, final String body, boolean durable, final String user, final String password) throws Exception {
    try {
        securityStore.check(addressInfo.getName(), CheckType.SEND, new SecurityAuth() {

            @Override
            public String getUsername() {
                return user;
            }

            @Override
            public String getPassword() {
                return password;
            }

            @Override
            public RemotingConnection getRemotingConnection() {
                return null;
            }
        });
        CoreMessage message = new CoreMessage(storageManager.generateID(), 50);
        if (headers != null) {
            for (String header : headers.keySet()) {
                message.putStringProperty(new SimpleString(header), new SimpleString(headers.get(header)));
            }
        }
        message.setType((byte) type);
        message.setDurable(durable);
        message.setTimestamp(System.currentTimeMillis());
        if (body != null) {
            if (type == Message.TEXT_TYPE) {
                message.getBodyBuffer().writeNullableSimpleString(new SimpleString(body));
            } else {
                message.getBodyBuffer().writeBytes(Base64.decode(body));
            }
        }
        message.setAddress(addressInfo.getName());
        postOffice.route(message, true);
        return "" + message.getMessageID();
    } catch (ActiveMQException e) {
        throw new IllegalStateException(e.getMessage());
    }
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SecurityAuth(org.apache.activemq.artemis.core.security.SecurityAuth) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage)

Example 10 with RemotingConnection

use of org.apache.activemq.artemis.spi.core.protocol.RemotingConnection in project activemq-artemis by apache.

the class QueueControlImpl method sendMessage.

@Override
public String sendMessage(final Map<String, String> headers, final int type, final String body, boolean durable, final String user, final String password) throws Exception {
    try {
        securityStore.check(queue.getAddress(), queue.getName(), CheckType.SEND, new SecurityAuth() {

            @Override
            public String getUsername() {
                return user;
            }

            @Override
            public String getPassword() {
                return password;
            }

            @Override
            public RemotingConnection getRemotingConnection() {
                return null;
            }
        });
        CoreMessage message = new CoreMessage(storageManager.generateID(), 50);
        if (headers != null) {
            for (String header : headers.keySet()) {
                message.putStringProperty(new SimpleString(header), new SimpleString(headers.get(header)));
            }
        }
        message.setType((byte) type);
        message.setDurable(durable);
        message.setTimestamp(System.currentTimeMillis());
        if (body != null) {
            if (type == Message.TEXT_TYPE) {
                message.getBodyBuffer().writeNullableSimpleString(new SimpleString(body));
            } else {
                message.getBodyBuffer().writeBytes(Base64.decode(body));
            }
        }
        message.setAddress(queue.getAddress());
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(queue.getID());
        message.putBytesProperty(Message.HDR_ROUTE_TO_IDS, buffer.array());
        postOffice.route(message, true);
        return "" + message.getMessageID();
    } catch (ActiveMQException e) {
        throw new IllegalStateException(e.getMessage());
    }
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SecurityAuth(org.apache.activemq.artemis.core.security.SecurityAuth) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ByteBuffer(java.nio.ByteBuffer) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage)

Aggregations

RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)84 Test (org.junit.Test)44 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)36 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)31 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)30 ActiveMQNotConnectedException (org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException)22 ClientSessionInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionInternal)21 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)19 CountDownLatch (java.util.concurrent.CountDownLatch)18 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)17 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)16 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)16 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)15 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)14 CoreRemotingConnection (org.apache.activemq.artemis.core.protocol.core.CoreRemotingConnection)13 ClientSessionFactoryInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal)12 Connection (javax.jms.Connection)11 Interceptor (org.apache.activemq.artemis.api.core.Interceptor)11 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)11 Session (javax.jms.Session)10