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();
}
}
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();
}
}
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;
}
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());
}
}
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());
}
}
Aggregations