Skip to main content

Setting up the Service Consumer

Availability-noteDeprecated

The CXF endpoint that listens for notifications should be defined on the consumer side. Here is how it looks like in Spring configuration file:

Setting up consumer side

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:library="http://services.talend.org/demos/Library/1.0"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
 
    <import resource="classpath:META-INF/cxf/cxf.xml" />
 
    <!-- CXF 3 JMS configuration style -->
    <import resource="classpath:META-INF/tesb/tesb-cxf-transport-jms.xml" />
 
 
    <jaxws:endpoint xmlns:library="http://services.talend.org/demos/Library/1.0"
        id="LibraryNotificationReceiver"
        address="jms:jndi-topic:dynamicTopics/newBooksTopic.topic?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp
;jndiConnectionFactoryName=ConnectionFactory&amp;jndiURL=tcp://localhost:61616"
        serviceName="library:LibraryProvider" endpointName="library:LibraryTopicPort"
        implementor="org.talend.services.demos.client.LibraryNotificationReceiverImpl">
        <jaxws:features>
            <bean class="org.apache.cxf.ws.addressing.WSAddressingFeature" />          
        </jaxws:features>
    </jaxws:endpoint>
 
</beans>

The following is an example of the implementation of the notification-receiving service:

Consumer side notification receiver

@@WebServiceProvider
public class LibraryNotificationReceiverImpl implements Library {

    @Resource
    private WebServiceContext wsContext;

    ...

    @Override
    public void newBooks(Date listDate, List<BookType> book) {
        System.out.println("****************************************************");
        System.out.println("*** newBooks notification is received **************");
        System.out.println("****************************************************");

        System.out.println("New books notification:");

        // Business logic here
    }
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!