use of org.apache.activemq.artemis.core.filter.Filter in project activemq-artemis by apache.
the class PostOfficeImpl method addBinding.
// TODO - needs to be synchronized to prevent happening concurrently with activate()
// (and possible removeBinding and other methods)
// Otherwise can have situation where createQueue comes in before failover, then failover occurs
// and post office is activated but queue remains unactivated after failover so delivery never occurs
// even though failover is complete
@Override
public synchronized void addBinding(final Binding binding) throws Exception {
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.beforeAddBinding(binding));
}
addressManager.addBinding(binding);
TypedProperties props = new TypedProperties();
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, binding.getType().toInt());
props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
Filter filter = binding.getFilter();
if (filter != null) {
props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filter.getFilterString());
}
String uid = UUIDGenerator.getInstance().generateStringUUID();
if (logger.isDebugEnabled()) {
logger.debug("ClusterCommunication::Sending notification for addBinding " + binding + " from server " + server);
}
managementService.sendNotification(new Notification(uid, CoreNotificationType.BINDING_ADDED, props));
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterAddBinding(binding));
}
}
use of org.apache.activemq.artemis.core.filter.Filter in project activemq-artemis by apache.
the class QueueControlImpl method expireMessages.
@Override
public int expireMessages(final String filterStr) throws Exception {
checkStarted();
clearIO();
try {
Filter filter = FilterImpl.createFilter(filterStr);
return queue.expireReferences(filter);
} catch (ActiveMQException e) {
throw new IllegalStateException(e.getMessage());
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.filter.Filter in project activemq-artemis by apache.
the class QueueControlImpl method moveMessages.
@Override
public int moveMessages(final int flushLimit, final String filterStr, final String otherQueueName, final boolean rejectDuplicates) throws Exception {
checkStarted();
clearIO();
try {
Filter filter = FilterImpl.createFilter(filterStr);
Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
if (binding == null) {
throw ActiveMQMessageBundle.BUNDLE.noQueueFound(otherQueueName);
}
int retValue = queue.moveReferences(flushLimit, filter, binding.getAddress(), rejectDuplicates, binding);
return retValue;
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.filter.Filter in project activemq-artemis by apache.
the class QueueControlImpl method browse.
@Override
public CompositeData[] browse(String filter) throws Exception {
checkStarted();
clearIO();
try {
int pageSize = addressSettingsRepository.getMatch(queue.getName().toString()).getManagementBrowsePageSize();
int currentPageSize = 0;
ArrayList<CompositeData> c = new ArrayList<>();
Filter thefilter = FilterImpl.createFilter(filter);
queue.flushExecutor();
try (LinkedListIterator<MessageReference> iterator = queue.browserIterator()) {
try {
while (iterator.hasNext() && currentPageSize++ < pageSize) {
MessageReference ref = iterator.next();
if (thefilter == null || thefilter.match(ref.getMessage())) {
c.add(OpenTypeSupport.convert(ref));
}
}
} catch (NoSuchElementException ignored) {
// this could happen through paging browsing
}
CompositeData[] rc = new CompositeData[c.size()];
c.toArray(rc);
return rc;
}
} catch (ActiveMQException e) {
throw new IllegalStateException(e.getMessage());
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.filter.Filter in project activemq-artemis by apache.
the class QueueControlImpl method sendMessagesToDeadLetterAddress.
@Override
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
checkStarted();
clearIO();
try {
Filter filter = FilterImpl.createFilter(filterStr);
return queue.sendMessagesToDeadLetterAddress(filter);
} finally {
blockOnIO();
}
}
Aggregations