Search in sources :

Example 1 with DistributedQueueHandlerContainerService

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);
    }
}
Also used : DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService)

Example 2 with DistributedQueueHandlerContainerService

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();
    }
}
Also used : DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService)

Example 3 with DistributedQueueHandlerContainerService

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();
    }
}
Also used : DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) QueueHandlerContainerService(jp.ossc.nimbus.service.queue.QueueHandlerContainerService) DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) DefaultQueueService(jp.ossc.nimbus.service.queue.DefaultQueueService)

Example 4 with DistributedQueueHandlerContainerService

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;
    }
}
Also used : DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) QueueHandlerContainerService(jp.ossc.nimbus.service.queue.QueueHandlerContainerService) DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) DefaultQueueService(jp.ossc.nimbus.service.queue.DefaultQueueService)

Example 5 with DistributedQueueHandlerContainerService

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();
    }
}
Also used : QueueHandlerContainerService(jp.ossc.nimbus.service.queue.QueueHandlerContainerService) DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) DistributedQueueHandlerContainerService(jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService) ServiceName(jp.ossc.nimbus.core.ServiceName) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

DistributedQueueHandlerContainerService (jp.ossc.nimbus.service.queue.DistributedQueueHandlerContainerService)5 QueueHandlerContainerService (jp.ossc.nimbus.service.queue.QueueHandlerContainerService)3 DefaultQueueService (jp.ossc.nimbus.service.queue.DefaultQueueService)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ServiceName (jp.ossc.nimbus.core.ServiceName)1