Search in sources :

Example 11 with Notify

use of org.oasis_open.docs.wsn.b_2.Notify in project cxf by apache.

the class Consumer method notify.

public void notify(@WebParam(partName = "Notify", name = "Notify", targetNamespace = "http://docs.oasis-open.org/wsn/b-2") Notify notify) {
    for (NotificationMessageHolderType message : notify.getNotificationMessage()) {
        if (context != null) {
            Object o = message.getMessage().getAny();
            if (o instanceof Element) {
                try {
                    o = context.createUnmarshaller().unmarshal((Element) o);
                    message.getMessage().setAny(o);
                } catch (JAXBException e) {
                // ignore, leave as a DOM
                }
            }
        }
        this.callback.notify(message);
    }
}
Also used : Element(org.w3c.dom.Element) JAXBException(javax.xml.bind.JAXBException) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)

Example 12 with Notify

use of org.oasis_open.docs.wsn.b_2.Notify in project cxf by apache.

the class AbstractNotificationBroker method handleNotify.

protected void handleNotify(Notify notify) {
    for (NotificationMessageHolderType messageHolder : notify.getNotificationMessage()) {
        W3CEndpointReference producerReference = messageHolder.getProducerReference();
        AbstractPublisher publisher = getPublisher(producerReference);
        if (publisher != null) {
            publisher.notify(messageHolder);
        }
    }
}
Also used : W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)

Example 13 with Notify

use of org.oasis_open.docs.wsn.b_2.Notify in project cxf by apache.

the class JmsPublisher method notify.

@Override
public void notify(NotificationMessageHolderType messageHolder) {
    Session session = null;
    try {
        Topic topic = topicConverter.toActiveMQTopic(messageHolder.getTopic());
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(topic);
        Notify notify = new Notify();
        notify.getNotificationMessage().add(messageHolder);
        StringWriter writer = new StringWriter();
        jaxbContext.createMarshaller().marshal(notify, writer);
        Message message = session.createTextMessage(writer.toString());
        producer.send(message);
    } catch (JMSException e) {
        LOGGER.log(Level.WARNING, "Error dispatching message", e);
    } catch (JAXBException e) {
        LOGGER.log(Level.WARNING, "Error dispatching message", e);
    } catch (InvalidTopicException e) {
        LOGGER.log(Level.WARNING, "Error dispatching message", e);
    } finally {
        if (session != null) {
            try {
                session.close();
            } catch (JMSException e) {
                LOGGER.log(Level.FINE, "Error closing session", e);
            }
        }
    }
}
Also used : StringWriter(java.io.StringWriter) Message(javax.jms.Message) Notify(org.oasis_open.docs.wsn.b_2.Notify) JAXBException(javax.xml.bind.JAXBException) JMSException(javax.jms.JMSException) MessageProducer(javax.jms.MessageProducer) Topic(javax.jms.Topic) Session(javax.jms.Session)

Example 14 with Notify

use of org.oasis_open.docs.wsn.b_2.Notify in project cxf by apache.

the class JmsPullPoint method store.

@Override
protected void store(NotificationMessageHolderType messageHolder) {
    try {
        initSession();
        Notify notify = new Notify();
        notify.getNotificationMessage().add(messageHolder);
        StringWriter writer = new StringWriter();
        jaxbContext.createMarshaller().marshal(notify, writer);
        synchronized (producerSession) {
            Message message = producerSession.createTextMessage(writer.toString());
            producer.send(message);
        }
    } catch (JMSException e) {
        LOGGER.log(Level.WARNING, "Error storing message", e);
        closeSession();
    } catch (JAXBException e) {
        LOGGER.log(Level.WARNING, "Error storing message", e);
    }
}
Also used : StringWriter(java.io.StringWriter) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) Notify(org.oasis_open.docs.wsn.b_2.Notify) JAXBException(javax.xml.bind.JAXBException) JMSException(javax.jms.JMSException)

Example 15 with Notify

use of org.oasis_open.docs.wsn.b_2.Notify in project bgpcep by opendaylight.

the class BGPSessionImplTest method testHoldTimerExpire.

@Test
public void testHoldTimerExpire() throws InterruptedException {
    this.bgpSession.sessionUp();
    checkIdleState(this.listener);
    Assert.assertEquals(3, this.receivedMsgs.size());
    Assert.assertTrue(this.receivedMsgs.get(2) instanceof Notify);
    final Notify error = (Notify) this.receivedMsgs.get(2);
    Assert.assertEquals(BGPError.HOLD_TIMER_EXPIRED.getCode(), error.getErrorCode().shortValue());
    Assert.assertEquals(BGPError.HOLD_TIMER_EXPIRED.getSubcode(), error.getErrorSubcode().shortValue());
    Mockito.verify(this.speakerListener).close();
}
Also used : Notify(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify) Test(org.junit.Test)

Aggregations

Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Notify)11 Test (org.junit.Test)9 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)7 JAXBException (javax.xml.bind.JAXBException)6 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open)5 Notification (org.opendaylight.yangtools.yang.binding.Notification)5 JMSException (javax.jms.JMSException)4 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.ProtocolVersion)3 Element (org.w3c.dom.Element)3 ByteBuf (io.netty.buffer.ByteBuf)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 QName (javax.xml.namespace.QName)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 Consumer (org.apache.cxf.wsn.client.Consumer)2