use of jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService in project nimbus by nimbus-org.
the class AbstractPublishMessageDispatcherService method preStartService.
@Override
protected void preStartService() throws Exception {
super.preStartService();
if (messageListenerQueueHandlerContainerServiceName != null) {
messageListenerQueueHandlerContainer = (QueueHandlerContainer) ServiceManagerFactory.getServiceObject(messageListenerQueueHandlerContainerServiceName);
} else {
if (messageListenerQueueSelectorServiceName != null) {
messageListenerQueueHandlerContainer = new DistributedQueueHandlerContainerService();
((DistributedQueueHandlerContainerService) messageListenerQueueHandlerContainer).create();
((DistributedQueueHandlerContainerService) messageListenerQueueHandlerContainer).setDistributedQueueSelectorServiceName(messageListenerQueueSelectorServiceName);
((DistributedQueueHandlerContainerService) messageListenerQueueHandlerContainer).start();
}
}
if (messageListenerQueueHandlerContainer != null) {
messageListenerQueueHandlerContainer.setQueueHandler(new MessageListenerQueueHandler());
}
if (messageSendQueueHandlerContainerServiceName != null) {
messageSendQueueHandlerContainer = (DistributedQueueHandlerContainerService) ServiceManagerFactory.getServiceObject(messageSendQueueHandlerContainerServiceName);
} else {
if (messageSendQueueSelectorServiceName != null) {
messageSendQueueHandlerContainer = new DistributedQueueHandlerContainerService();
messageSendQueueHandlerContainer.create();
messageSendQueueHandlerContainer.setDistributedQueueSelectorServiceName(messageSendQueueSelectorServiceName);
messageSendQueueHandlerContainer.start();
}
}
messageSendDistributedQueueSelector = (DistributedQueueSelector) ServiceManagerFactory.getServiceObject(messageSendQueueHandlerContainer.getDistributedQueueSelectorServiceName());
if (messageSendQueueHandlerContainer != null) {
messageSendQueueHandlerContainer.setQueueHandler(new MessageSendQueueHandler());
messageSendQueueHandlerContainer.accept();
}
if (messageSendExceptionHandlerMappingServiceName != null) {
messageSendExceptionHandler = (ExceptionHandlerMappingService) ServiceManagerFactory.getServiceObject(messageSendExceptionHandlerMappingServiceName);
}
}
use of jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService in project nimbus by nimbus-org.
the class ServerConnectionImpl method initAsynchSend.
private void initAsynchSend(ServiceName queueFactoryServiceName, int clientQueueDistributedSize) throws Exception {
if (clientQueueDistributedSize > 0) {
queueSelector = new ClientDistributedQueueSelector();
queueSelector.create();
queueSelector.setDistributedSize(clientQueueDistributedSize);
if (queueFactoryServiceName != null) {
queueSelector.setQueueFactoryServiceName(queueFactoryServiceName);
}
queueSelector.start();
asynchSendQueueHandlerContainer = new DistributedQueueHandlerContainerService();
asynchSendQueueHandlerContainer.create();
asynchSendQueueHandlerContainer.setDistributedQueueSelector(queueSelector);
asynchSendQueueHandlerContainer.setQueueHandler(new SendQueueHandler());
asynchSendQueueHandlerContainer.start();
}
}
use of jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService in project nimbus by nimbus-org.
the class ServerConnectionImpl method initAsynchSend.
private void initAsynchSend(ServiceName queueServiceName, ServiceName queueFactoryServiceName, int clientQueueDistributedSize) throws Exception {
if (clientQueueDistributedSize > 0) {
asynchAcceptQueueHandlerContainer = new QueueHandlerContainerService();
asynchAcceptQueueHandlerContainer.create();
if (queueServiceName == null) {
DefaultQueueService acceptQueue = new DefaultQueueService();
acceptQueue.create();
acceptQueue.start();
asynchAcceptQueueHandlerContainer.setQueueService(acceptQueue);
} else {
asynchAcceptQueueHandlerContainer.setQueueServiceName(queueServiceName);
}
asynchAcceptQueueHandlerContainer.setQueueHandlerSize(1);
asynchAcceptQueueHandlerContainer.setQueueHandler(new AsynchAcceptQueueHandler());
asynchAcceptQueueHandlerContainer.setIgnoreNullElement(true);
asynchAcceptQueueHandlerContainer.setWaitTimeout(1000l);
asynchAcceptQueueHandlerContainer.start();
queueSelector = new ClientDistributedQueueSelector();
queueSelector.create();
queueSelector.setDistributedSize(clientQueueDistributedSize);
if (queueFactoryServiceName != null) {
queueSelector.setQueueFactoryServiceName(queueFactoryServiceName);
}
queueSelector.start();
asynchSendQueueHandlerContainer = new DistributedQueueHandlerContainerService();
asynchSendQueueHandlerContainer.create();
asynchSendQueueHandlerContainer.setDistributedQueueSelector(queueSelector);
asynchSendQueueHandlerContainer.setQueueHandler(new SendQueueHandler());
asynchSendQueueHandlerContainer.setIgnoreNullElement(true);
asynchSendQueueHandlerContainer.setWaitTimeout(1000l);
asynchSendQueueHandlerContainer.start();
}
}
use of jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService in project nimbus by nimbus-org.
the class ServerConnectionImpl method initAsynchSend.
private void initAsynchSend(ServiceName queueServiceName, ServiceName queueFactoryServiceName, int asynchSendThreadSize, boolean isMulticast) throws Exception {
if (asynchSendThreadSize <= 0) {
return;
}
asynchAcceptQueueHandlerContainer = new QueueHandlerContainerService();
asynchAcceptQueueHandlerContainer.create();
if (queueServiceName == null) {
DefaultQueueService acceptQueue = new DefaultQueueService();
acceptQueue.create();
acceptQueue.start();
asynchAcceptQueueHandlerContainer.setQueueService(acceptQueue);
} else {
asynchAcceptQueueHandlerContainer.setQueueServiceName(queueServiceName);
}
asynchAcceptQueueHandlerContainer.setQueueHandlerSize(1);
asynchAcceptQueueHandlerContainer.setQueueHandler(new AsynchAcceptQueueHandler());
asynchAcceptQueueHandlerContainer.setIgnoreNullElement(true);
asynchAcceptQueueHandlerContainer.setWaitTimeout(1000l);
asynchAcceptQueueHandlerContainer.start();
if (!isMulticast) {
queueSelector = new ClientDistributedQueueSelector();
queueSelector.create();
queueSelector.setDistributedSize(asynchSendThreadSize);
if (queueFactoryServiceName != null) {
queueSelector.setQueueFactoryServiceName(queueFactoryServiceName);
}
queueSelector.start();
DistributedQueueHandlerContainerService distributedQueueHandlerContainer = new DistributedQueueHandlerContainerService();
distributedQueueHandlerContainer.create();
distributedQueueHandlerContainer.setDistributedQueueSelector(queueSelector);
distributedQueueHandlerContainer.setQueueHandler(new SendQueueHandler());
distributedQueueHandlerContainer.setIgnoreNullElement(true);
distributedQueueHandlerContainer.setWaitTimeout(1000l);
distributedQueueHandlerContainer.start();
asynchSendQueueHandlerContainer = distributedQueueHandlerContainer;
}
}
use of jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService in project nimbus by nimbus-org.
the class MessageReceiverService method startService.
public void startService() throws Exception {
if (messageQueueDistributedSize > 1) {
messageQueueSelector = new MessageDistributedQueueSelector();
messageQueueSelector.setServiceManagerName(getServiceManagerName());
messageQueueSelector.setServiceName(getServiceName() + "$MessageQueueSelector");
messageQueueSelector.create();
messageQueueSelector.setDistributedSize(messageQueueDistributedSize);
if (messageQueueFactoryServiceName != null) {
messageQueueSelector.setQueueFactoryServiceName(messageQueueFactoryServiceName);
}
messageQueueSelector.start();
DistributedQueueHandlerContainerService queueHandlerContainer = new DistributedQueueHandlerContainerService();
queueHandlerContainer.setServiceManagerName(getServiceManagerName());
queueHandlerContainer.setServiceName(getServiceName() + "$MessageQueueHandlerContainer");
queueHandlerContainer.create();
queueHandlerContainer.setDistributedQueueSelector(messageQueueSelector);
queueHandlerContainer.setQueueHandler(new MessageQueueHandler());
queueHandlerContainer.setIgnoreNullElement(true);
queueHandlerContainer.setWaitTimeout(1000l);
queueHandlerContainer.start();
messageQueueHandlerContainer = queueHandlerContainer;
} else if (messageQueueDistributedSize == 1) {
QueueHandlerContainerService queueHandlerContainer = new QueueHandlerContainerService();
queueHandlerContainer.setServiceManagerName(getServiceManagerName());
queueHandlerContainer.setServiceName(getServiceName() + "$MessageQueueHandlerContainer");
queueHandlerContainer.create();
queueHandlerContainer.setQueueServiceName(messageQueueFactoryServiceName);
queueHandlerContainer.setQueueHandler(new MessageQueueHandler());
queueHandlerContainer.setIgnoreNullElement(true);
queueHandlerContainer.setWaitTimeout(1000l);
queueHandlerContainer.start();
messageQueueHandlerContainer = queueHandlerContainer;
}
if (messageListenerQueueDistributedSize > 0) {
messageListenerQueueSelector = new MessageListenerDistributedQueueSelector();
messageListenerQueueSelector.setServiceManagerName(getServiceManagerName());
messageListenerQueueSelector.setServiceName(getServiceName() + "$MessageListenerQueueSelector");
messageListenerQueueSelector.create();
messageListenerQueueSelector.setDistributedSize(messageListenerQueueDistributedSize);
if (messageListenerQueueFactoryServiceName != null) {
messageListenerQueueSelector.setQueueFactoryServiceName(messageListenerQueueFactoryServiceName);
}
messageListenerQueueSelector.start();
messageListenerQueueHandlerContainer = new DistributedQueueHandlerContainerService();
messageListenerQueueHandlerContainer.setServiceManagerName(getServiceManagerName());
messageListenerQueueHandlerContainer.setServiceName(getServiceName() + "$MessageListenerQueueHandlerContainer");
messageListenerQueueHandlerContainer.create();
messageListenerQueueHandlerContainer.setDistributedQueueSelector(messageListenerQueueSelector);
messageListenerQueueHandlerContainer.setQueueHandler(new MessageListenerQueueHandler());
messageListenerQueueHandlerContainer.setIgnoreNullElement(true);
messageListenerQueueHandlerContainer.setWaitTimeout(1000l);
messageListenerQueueHandlerContainer.start();
}
if (messageLatencyPerformanceRecorderServiceName != null) {
messageLatencyPerformanceRecorder = (PerformanceRecorder) ServiceManagerFactory.getServiceObject(messageLatencyPerformanceRecorderServiceName);
}
clientConnection = new WrappedClientConnection();
if (isConnectOnStart) {
connect();
}
if (registeredListenerMap.size() != 0) {
final Iterator listenerEntries = registeredListenerMap.entrySet().iterator();
while (listenerEntries.hasNext()) {
final Map.Entry listenerEntry = (Map.Entry) listenerEntries.next();
Object listenerObj = listenerEntry.getKey();
MessageListener listener = null;
if (listenerObj instanceof ServiceName) {
listener = (MessageListener) ServiceManagerFactory.getServiceObject((ServiceName) listenerObj);
} else {
listener = (MessageListener) listenerObj;
}
final Map subjectMap = (Map) listenerEntry.getValue();
final Iterator subjectEntries = subjectMap.entrySet().iterator();
while (subjectEntries.hasNext()) {
final Map.Entry subjectEntry = (Map.Entry) subjectEntries.next();
String subject = (String) subjectEntry.getKey();
Set keySet = (Set) subjectEntry.getValue();
if (keySet.remove(null)) {
addSubject(listener, subject);
}
addSubject(listener, subject, (String[]) keySet.toArray(new String[keySet.size()]));
}
}
}
if (isStartReceiveOnStart) {
startReceive();
}
}
Aggregations