private void dispatchExchange(Object response) throws CamelException { LOG.debug("Consumer Dispatching the received notification along the route"); Exchange exchange = sipSubscriber.getEndpoint().createExchange(ExchangePattern.InOnly); exchange.getIn().setBody(response); try { sipSubscriber.getProcessor().process(exchange); } catch (Exception e) { throw new CamelException("Error in consumer while dispatching exchange", e); } }
public synchronized void processNotify( RequestEvent requestEvent, ServerTransaction serverTransactionId) { LOG.debug("Notification received at Subscriber"); SipProvider provider = (SipProvider) requestEvent.getSource(); Request notify = requestEvent.getRequest(); try { if (serverTransactionId == null) { LOG.info("ServerTransaction is null. Creating new Server transaction"); serverTransactionId = provider.getNewServerTransaction(notify); } Dialog dialog = serverTransactionId.getDialog(); if (dialog != subscriberDialog) { forkedDialog = dialog; } // Dispatch the response along the route dispatchExchange(notify.getContent()); // Send back an success response Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify); response.addHeader(sipSubscriber.getConfiguration().getContactHeader()); serverTransactionId.sendResponse(response); SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME); // Subscription is terminated? if (subscriptionState.getState().equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) { LOG.info("Subscription state is terminated. Deleting the current dialog"); dialog.delete(); } } catch (Exception e) { LOG.error("Exception thrown during Notify processing in the SipSubscriptionListener.", e); } }