@Override public void run() { QueueService service = getService(); NodeEngine nodeEngine = getNodeEngine(); Config config = nodeEngine.getConfig(); for (Map.Entry<String, QueueContainer> entry : migrationData.entrySet()) { String name = entry.getKey(); QueueContainer container = entry.getValue(); QueueConfig conf = config.findQueueConfig(name); container.setConfig(conf, nodeEngine, service); service.addContainer(name, container); } }
@Override protected Object call() { final ClientEndpoint endpoint = getEndpoint(); final QueueService service = getService(QueueService.SERVICE_NAME); final Data partitionKey = serializationService.toData(parameters.name); ItemListener listener = new ItemListener() { @Override public void itemAdded(ItemEvent item) { send(item); } @Override public void itemRemoved(ItemEvent item) { send(item); } private void send(ItemEvent event) { if (endpoint.isAlive()) { if (!(event instanceof DataAwareItemEvent)) { throw new IllegalArgumentException( "Expecting: DataAwareItemEvent, Found: " + event.getClass().getSimpleName()); } DataAwareItemEvent dataAwareItemEvent = (DataAwareItemEvent) event; Data item = dataAwareItemEvent.getItemData(); ClientMessage clientMessage = QueueAddListenerCodec.encodeItemEvent( item, event.getMember().getUuid(), event.getEventType().getType()); sendClientMessage(partitionKey, clientMessage); } } }; String registrationId = service.addItemListener( parameters.name, listener, parameters.includeValue, parameters.localOnly); endpoint.addListenerDestroyAction(QueueService.SERVICE_NAME, parameters.name, registrationId); return registrationId; }