use of com.swiftmq.ms.MessageSelector in project swiftmq-client by iitsoftware.
the class SessionImpl method createDurableSubscriber.
public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException {
verifyState();
if (topic == null)
throw new InvalidDestinationException("createDurableSubscriber, topic is null!");
if (name == null)
throw new NullPointerException("createDurableSubscriber, name is null!");
if (myConnection.getClientID() == null)
throw new IllegalStateException("unable to create durable subscriber, no client ID has been set");
try {
SwiftUtilities.verifyDurableName(name);
} catch (Exception e) {
throw new JMSException(e.getMessage());
}
TopicSubscriberImpl ts = null;
CreateDurableReply reply = null;
try {
String ms = messageSelector;
if (messageSelector != null && messageSelector.trim().length() == 0)
ms = null;
if (ms != null) {
MessageSelector msel = new MessageSelector(ms);
msel.compile();
}
reply = (CreateDurableReply) requestRegistry.request(new CreateDurableRequest(this, dispatchId, (TopicImpl) topic, ms, noLocal, name));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int tsId = reply.getTopicSubscriberId();
ts = new DurableTopicSubscriberImpl(transacted, acknowledgeMode, requestRegistry, topic, messageSelector, this, noLocal, name);
ts.setServerQueueConsumerId(tsId);
ts.setDoAck(!transacted && acknowledgeMode != Session.CLIENT_ACKNOWLEDGE);
addMessageConsumerImpl(ts);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (ts);
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-client by iitsoftware.
the class SessionImpl method createSubscriber.
public TopicSubscriber createSubscriber(Topic topic, String messageSelector, boolean noLocal) throws JMSException {
verifyState();
if (topic == null)
throw new InvalidDestinationException("createSubscriber, topic is null!");
if (topic instanceof TemporaryTopicImpl && !((TemporaryTopicImpl) topic).isCreatingSession(this))
throw new JMSException("A receiver on a TemporaryTopic can only be created from the session the temporary topic was created from");
TopicSubscriberImpl ts = null;
CreateSubscriberReply reply = null;
try {
String ms = messageSelector;
if (messageSelector != null && messageSelector.trim().length() == 0)
ms = null;
if (ms != null) {
MessageSelector msel = new MessageSelector(ms);
msel.compile();
}
reply = (CreateSubscriberReply) requestRegistry.request(new CreateSubscriberRequest(this, dispatchId, (TopicImpl) topic, ms, noLocal, true));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
int tsId = reply.getTopicSubscriberId();
ts = new TopicSubscriberImpl(transacted, acknowledgeMode, requestRegistry, topic, messageSelector, this, noLocal);
ts.setServerQueueConsumerId(tsId);
ts.setDoAck(false);
ts.setRecordLog(false);
addMessageConsumerImpl(ts);
} else {
throw ExceptionConverter.convert(reply.getException());
}
return (ts);
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class QueueWireTapInput method start.
@Override
public void start() throws Exception {
if (selector != null) {
messageSelector = new MessageSelector(selector);
messageSelector.compile();
}
queue = new ArrayBlockingQueue<MessageImpl>(bufferSize);
AbstractQueue queue = ctx.ctx.queueManager.getQueueForInternalUse(destinationName);
if (queue == null)
throw new Exception("Queue '" + destinationName + "' is undefined!");
queue.addWireTapSubscriber(name, this);
started = true;
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class TopicInput method start.
@Override
public void start() throws Exception {
if (started)
return;
if (!ctx.ctx.topicManager.isTopicDefined(destinationName))
ctx.ctx.topicManager.createTopic(destinationName);
MessageSelector ms = null;
if (selector != null) {
ms = new MessageSelector(selector);
ms.compile();
}
if (durable) {
ActiveLogin dlogin = ctx.ctx.authenticationSwiftlet.createActiveLogin(clientId, "DURABLE");
dlogin.setClientId(clientId);
TopicImpl topic = ctx.ctx.topicManager.verifyTopic(new TopicImpl(destinationName));
queueName = ctx.ctx.topicManager.subscribeDurable(durableName, topic, ms, false, dlogin);
} else {
queueName = ctx.ctx.queueManager.createTemporaryQueue();
subscriberId = ctx.ctx.topicManager.subscribe(destinationName, ms, false, queueName, true);
}
QueueReceiver receiver = ctx.ctx.queueManager.createQueueReceiver(queueName, (ActiveLogin) null, null);
messageProcessor = new QueueMessageProcessor(ctx, this, receiver, null);
messageProcessor.restart();
started = true;
}
use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class HeapMemory method remove.
@Override
public Memory remove(String selector) throws Exception {
MessageSelector sel = new MessageSelector(selector);
sel.compile();
List<Entry> list = all();
for (int i = 0; i < list.size(); i++) {
Entry entry = list.get(i);
if (entry.message.isSelected(sel))
removeByKey(entry.key);
}
return this;
}
Aggregations