logo
down
shadow

Adding advice to a mail inbound channel adapter


Adding advice to a mail inbound channel adapter

By : Ekstc
Date : November 22 2020, 09:00 AM
Hope that helps I am not entirely clear about what you are trying to do but inbound channel adapters are not message handlers (hence there is no handler bean). Polled inbound adapters are MessageSource but advising the source won't help because we invoke receive() and then send the message to the flow.
You can, however, add Advice objects to the 's advice-chain.
code :
@Autowired
private SourcePollingChannelAdapter adapter;

...

@Test
public ... {

    this.adapter.setAdviceChain(...);
    this.adapter.start();
    ...
}
@Autowired
private SourcePollingChannelAdapter adapter;

@Test
public void testAdvice() throws Exception {
    List<Advice> adviceChain = new ArrayList<Advice>();
    final AtomicBoolean hasMessage = new AtomicBoolean();
    final CountDownLatch latch = new CountDownLatch(1);
    class MessageDetector extends AbstractMessageSourceAdvice {

        @Override
        public boolean beforeReceive(MessageSource<?> source) {
            return true;
        }

        @Override
        public Message<?> afterReceive(Message<?> result, MessageSource<?> source) {
            hasMessage.set(result != null);
            System.out.println("has message:" + hasMessage.get());
            return result;
        }

    }
    adviceChain.add(new MessageDetector());
    class MyAdvice implements MethodInterceptor {

        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            System.out.println("in myAdvice before, hasmessage:" + hasMessage.get());
            Object proceed = invocation.proceed();
            System.out.println("in myAdvice after, hasmessage:" + hasMessage.get());
            latch.countDown();
            return proceed;
        }

    }
    adviceChain.add(new MyAdvice());
    adapter.setAdviceChain(adviceChain);
    new DirectFieldAccessor(adapter).setPropertyValue("initialized", false);
    adapter.start();
    assertTrue(latch.await(10, TimeUnit.SECONDS));
}
@Autowired
private SourcePollingChannelAdapter adapter;

@Test
public void testAdvice() throws Exception {
    List<Advice> adviceChain = new ArrayList<Advice>();
    final AtomicBoolean hasMessage = new AtomicBoolean();
    final CountDownLatch latch = new CountDownLatch(1);
    class MessageDetector extends AbstractMessageSourceAdvice {

        @Override
        public boolean beforeReceive(MessageSource<?> source) {
            return true;
        }

        @Override
        public Message<?> afterReceive(Message<?> result, MessageSource<?> source) {
            hasMessage.set(result != null);
            System.out.println("has message:" + hasMessage.get());
            return result;
        }

    }
    adviceChain.add(new MessageDetector());
    class MyAdvice implements MethodInterceptor {

        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            System.out.println("in myAdvice before, hasmessage:" + hasMessage.get());
            Object proceed = invocation.proceed();
            System.out.println("in myAdvice after, hasmessage:" + hasMessage.get());
            latch.countDown();
            return proceed;
        }

    }
    adviceChain.add(new MyAdvice());
    adapter.setAdviceChain(adviceChain);
    adapter.setTrigger(new Trigger() {

        @Override
        public Date nextExecutionTime(TriggerContext triggerContext) {
            return null; // never poll
        }
    });
    adapter.start();
    adapter.stop();
    adapter.setTrigger(new PeriodicTrigger(1000));
    adapter.start();
    assertTrue(latch.await(10, TimeUnit.SECONDS));
}


Share : facebook icon twitter icon
Spring Integration - Delay poller for mail inbound channel adapter not considered

Spring Integration - Delay poller for mail inbound channel adapter not considered


By : BigDataUser
Date : March 29 2020, 07:55 AM
hope this fix your issue From the documentation it sounds like this is the expected behavior, polling will be done repeatedly until the max-messages-per-poll number is satisfied.
So when you had a low max-messages-per-poll, this number was satisfied by a few polling calls which probably got completed fairly quickly and you could see a clean fixed-delay call. When you had a high max-messages-per-poll, it took probably quite a few poll calls to satisfy the max-messages-per-poll call.
What is the appropriate way to trigger spring-integration int-mail:inbound-channel-adapter?

What is the appropriate way to trigger spring-integration int-mail:inbound-channel-adapter?


By : frankk
Date : March 29 2020, 07:55 AM
this will help Don't want to find similar solution, which I showed earlier, even on SO. But as you say that you are newbie, so I just provide the solution for you.
Well, supose you have something like this now:
code :
<int-mail:inbound-channel-adapter store-uri="pop3:foo"
                              channel="channel">
      <int:poller fixed-rate="60000"/>
</int-mail:inbound-channel-adapter>
<beans:bean id="pop3MailReceiver" class="org.springframework.integration.mail.Pop3MailReceiver"/>

<int:inbound-channel-adapter channel="getEmailsChannel" expression="''">
    <int:poller fixed-rate="60000"/>
</int:inbound-channel-adapter>

<int:service-activator input-channel="getEmailsChannel" output-channel="processEmailsChannel"
                               expression="@pop3MailReceiver.receive()"/>
How to add <int:request-handler-advice-chain /> in Spring Integration FTP Inbound Channel Adapter

How to add <int:request-handler-advice-chain /> in Spring Integration FTP Inbound Channel Adapter


By : Wolf
Date : March 29 2020, 07:55 AM
help you fix your problem Request handler advices can only be applied to message handlers; an inbound channel adapter is not a message handler.
See smart polling for how to apply an advice to polled channel adapter.
mail:inbound-channel-adapter return type

mail:inbound-channel-adapter return type


By : john
Date : March 29 2020, 07:55 AM
To fix the issue you can do The ImapIdleChannelAdapter is an event-driven component. It’s not a source to poll. It will produce messages by its own internal tasks.
You must remove an @InboundChannelAdapter from its configuration and add simple @Bean. The channel must be configured one ImapIdleChannelAdapter object directly.
How to check if a mail:inbound-channel-adapter in Spring Integration is running?

How to check if a mail:inbound-channel-adapter in Spring Integration is running?


By : user25080
Date : March 29 2020, 07:55 AM
will be helpful for those in need i'm using control-bus to start and stop a mail:inbound-channel-adapter in Spring Integration. Is there any way to check the channel status? If it's running or not? , Use a messaging gateway to send a message to the control bus...
Related Posts Related Posts :
  • Add and Subtract Times
  • torch.Tensor manipulation - Comparing two vectors
  • Clojure function that waits on the completion of another function before executing
  • Specman: How to find if a list of bytes exists in another list taking order of the list into account
  • Should I use docker-compose start or docker-compose up -d
  • is printf privileged instruction?
  • Sphinx arbitrary cross-reference destroys paragraph break?
  • Listing all `dynamic` variables for a class in Swift2
  • How to use SPARQL query to get field and field count at the same time?
  • slick carousel in grid mode cutting off bottom of second row
  • Checkbox submission to display text?
  • Using Presto on Cloud Dataproc with Google Cloud SQL?
  • Safari/Babel/Webpack Const declarations are not supported in strict mode
  • Unable to initialize firebase project using firebase-tools
  • gvNIX datatables set sorting options table (which fields)
  • How do you create a scrollable TW3ListMenu at run-time?
  • Visual Studio 2015 does not remember undocked windows position between debug and coding views
  • Data collection in Universal Recommender
  • phpexcel select cell after freezePane()
  • fullcalendar.io removeEventSource on dynamic events
  • Parsing string timestamp with time zone in 3-digit format followed by 'Z'
  • Ebay File Exchange Custom Field Removal or Rename
  • How to convert RelayJS connection to plain array?
  • Facebook api undefined issue
  • Issue creating stream definitions via rest interface
  • Why are there 2 registers in ARM for enabling/disabling interrupts instead of 1?
  • dnx ef is not recognized although defined in project.json
  • SHA-512 is it possible to get a collission in the first byte?
  • Cucumber jvm - specify multiple tags to ignore in After hook
  • Swift 2 run code if no exceptions
  • Why do we get to pick the source in an NP-completeness reduction?
  • Increment Number OnInsert()
  • How do you avoid repeating styles in shadow DOM?
  • Why would Capybara not allow fill_in when find for the same element works?
  • CKEditor's ckbuilder throws exception when build.sh is run
  • How do I make time$ work with ctrl+t e in ACL2 and emacs?
  • NVIC_SystemReset() stuck in while loop (STM32F302VB)
  • cypher retrieve nodes within a specific range time
  • Sharepoint Workflow Condtions
  • Display custom page when error happens in Koa
  • Python 3.5 [with tkinter buttons]
  • Rubymine 8: How to turn off Database Detector
  • Just getting started with Manatee.trello and encountering the following error
  • Digital Representation in different forms of videos
  • Add Ounces (oz) option to mass unit setting in Kentico
  • URL as barcode (not QR)
  • SonarQube analysis fails after upgrade to 3.7.1 rules
  • Creating Ratio with attributes of different dimensions
  • Python script not working if i run it using full path
  • Twilio - Using JavaScript?
  • Where can ratpack-jackson version 1.1.1 be resolved?
  • SQLAlchemy. How to use the mapper() without a primary key?
  • GCS slow upload from pod inside kubernetes GKE
  • type="number" use only CustomValidator
  • ErrorException in PlaceController.php line 101: Trying to get property of non-object - Laravel 5.1*
  • MDX - do no show contacts if the linked action is selected
  • Remove Right Column on Registration page
  • Angular UI Router: Dedicated UI-View
  • Maya 2015 Suggestions for speeding up exporting when scene has animation
  • pthreads, mq_timedreceive, pthread_cond_timedwait and CLOCK_REALTIME
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co