Announcement Announcement Module
Collapse
No announcement yet.
Spring Integration - JMX Polling Start/Stop Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Integration - JMX Polling Start/Stop Problem

    I have defined poller configurations in config.xml and polling starts during application start itself. If am polling some XYZ Folder, at particular time interval I want to stop polling manually. If required I should able to start the polling from where it has been stopped.

    I have achieved this using JMX with Spring Int but still getting null pointer Exception. Can anyone tell how to achieve this issue.??

  • #2
    You said you are getting NPE. Can you please post a stack trace?

    Comment


    • #3
      Config.xml
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      	<!-- CHANNEL CONFIGURATIONS -->
      <int-file:inbound-channel-adapter id="filesInChannel"
      	directory="file:${inputDirectory}" filename-pattern="*${configFileExtension}"
      	prevent-duplicates="false">
      	<int:poller ref="mainPoller" />
      </int-file:inbound-channel-adapter>
      	<!-- POLLER CONFIGURATIONS -->
      <int:poller id="filePoller" task-executor="fileTaskExecutor"
      	fixed-rate="1000">
      	<int:transactional isolation="DEFAULT" propagation="REQUIRED"
      		timeout="120" transaction-manager="transactionManager" />
      </int:poller>
      	<!-- JMX CONFIGURATIONS -->
      <context:mbean-export default-domain="myDomain" />
      <context:mbean-server />
      <bean id="serverConnector"
      	class="org.springframework.jmx.support.ConnectorServerFactoryBean"
      	depends-on="rmiRegistry">
      	<property name="objectName" value="connector:name=rmi" />
      	<property name="serviceUrl"
      		value="service:jmx:rmi:///jndi/rmi://localhost:1099/server" />
      </bean>
      <bean id="rmiRegistry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
      	<property name="port" value="1099" />
      </bean>
      <bean id="clientConnector"
      	class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
      	<property name="serviceUrl"
      		value="service:jmx:rmi:///jndi/rmi://localhost:1099/server" />
      </bean>
      <bean id="testProxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
      	<property name="server" ref="clientConnector" />
      	<property name="objectName" value="Somevalue" />
      	<property name="proxyInterface" value="com.file.jmx.PollAdapter" />
      </bean>
      <bean id="pollAdapter" class="com.file.jmx.PollAdapterImpl"
      	lazy-init="false" />
      </beans>
      PollAdapter is an interface which has an impl class PollAdapterImpl

      Code:
      private AbstractPollingEndpoint adapter;
      	public AbstractPollingEndpoint getAdapter() {
      		return adapter;}
      	public void setAdapter(AbstractPollingEndpoint adapter) {
      		this.adapter = adapter;}
      	public void startPoll() throws Exception {
      		this.adapter.start();}
      	public void stopPoll() throws Exception {
      		this.adapter.stop(); }
      I am calling this start and stop from a servlet like this. If I send like this I am getting NPE
      Code:
      protected void doGet(HttpServletRequest request,
      			HttpServletResponse response) {
      		WebApplicationContext springContext = WebApplicationContextUtils
      				.getWebApplicationContext(getServletContext());
      		PollAdapter myBean = (PollAdapter) springContext
      				.getBean("testProxy");
      			myBean.startPoll();
      		}

      Comment

      Working...
      X