How to create a LIFO Queue ChannelHow do I efficiently iterate over each entry in a Java Map?Create ArrayList from arrayHow do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How do I create a file and write to it in Java?How do I convert a String to an int in Java?How do I fix 'android.os.NetworkOnMainThreadException'?Creating a memory leak with JavaError sending message to a QueueChannel from chain in spring integration

Slow query when having 'contains' and '=' together in where clause

Which version of the Pigeonhole principle is correct? One is far stronger than the other

Why has the UK has not yet signed a continuity trade agreement with Turkey?

What was the earliest microcomputer Logo language implementation?

Wrong Schengen Visa exit stamp on my passport, who can I complain to?

Do household ovens ventilate heat to the outdoors?

Can Brexit be undone in an emergency?

How do you determine which representation of a function to use for Newton's method?

Very lazy puppy

Story/1980s sci fi anthology novel where a man is sucked into another world through a gold painting

In Bb5 systems against the Sicilian, why does White exchange their b5 bishop without playing a6?

Plot irregular circle in latex

Could the Orion project pusher plate model be used for asteroid deflection?

Where did Otto von Bismarck say "lying awake all night, hating"?

What is the word for a person who destroys monuments?

Talk about Grandpa's weird talk: Who are these folks?

Explanation of 申し訳ございません

Applications of mathematics in clinical setting

How do rulers get rich from war?

Delete empty subfolders, keep parent folder

What's the purpose of autocorrelation?

Can I separate garlic into cloves for storage?

What does the Free Recovery sign (UK) actually mean?

Why are there no programmes / playbills for movies?



How to create a LIFO Queue Channel


How do I efficiently iterate over each entry in a Java Map?Create ArrayList from arrayHow do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How can I create an executable JAR with dependencies using Maven?How do I create a file and write to it in Java?How do I convert a String to an int in Java?How do I fix 'android.os.NetworkOnMainThreadException'?Creating a memory leak with JavaError sending message to a QueueChannel from chain in spring integration






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















Currently I am using a Queue Channel in my Integration flow but it uses a FIFO way of extraction. Is there a way to change it to LIFO?



Also, is there a way to remove messages from the Queue based on a property?



I suspect I will need to use a PriorityChannel for switching from FIFO to LIFO but I can't figure out how it would be accomplished.



@Bean
fun notificationChannel(): MessageChannel
return MessageChannels.queue().get()



For example, my QueueChannel will be filled with messages containing userId. Since I'm only interested in the latest state of the userId message I want to use LIFO and remove all messages with the same userId as the latest message.










share|improve this question






























    2















    Currently I am using a Queue Channel in my Integration flow but it uses a FIFO way of extraction. Is there a way to change it to LIFO?



    Also, is there a way to remove messages from the Queue based on a property?



    I suspect I will need to use a PriorityChannel for switching from FIFO to LIFO but I can't figure out how it would be accomplished.



    @Bean
    fun notificationChannel(): MessageChannel
    return MessageChannels.queue().get()



    For example, my QueueChannel will be filled with messages containing userId. Since I'm only interested in the latest state of the userId message I want to use LIFO and remove all messages with the same userId as the latest message.










    share|improve this question


























      2












      2








      2








      Currently I am using a Queue Channel in my Integration flow but it uses a FIFO way of extraction. Is there a way to change it to LIFO?



      Also, is there a way to remove messages from the Queue based on a property?



      I suspect I will need to use a PriorityChannel for switching from FIFO to LIFO but I can't figure out how it would be accomplished.



      @Bean
      fun notificationChannel(): MessageChannel
      return MessageChannels.queue().get()



      For example, my QueueChannel will be filled with messages containing userId. Since I'm only interested in the latest state of the userId message I want to use LIFO and remove all messages with the same userId as the latest message.










      share|improve this question














      Currently I am using a Queue Channel in my Integration flow but it uses a FIFO way of extraction. Is there a way to change it to LIFO?



      Also, is there a way to remove messages from the Queue based on a property?



      I suspect I will need to use a PriorityChannel for switching from FIFO to LIFO but I can't figure out how it would be accomplished.



      @Bean
      fun notificationChannel(): MessageChannel
      return MessageChannels.queue().get()



      For example, my QueueChannel will be filled with messages containing userId. Since I'm only interested in the latest state of the userId message I want to use LIFO and remove all messages with the same userId as the latest message.







      java spring kotlin spring-integration






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 13:23









      Radoslav HubenovRadoslav Hubenov

      691 silver badge6 bronze badges




      691 silver badge6 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1
















          It sounds like you don't really want LIFO, you just want the latest for a given condition.



          But, regardless, Queue is a pretty simple interface; it only has a handful of methods and the QueueChannel only uses poll(), offer() and size().



          So it should be simple to create a custom queue, e.g. based on a thread-safe ConcurrentHashMap<String, Message<?>> with the key being your condition.






          share|improve this answer

























          • How would I have to proceed so that the older messages with the same userId in the queue are discarded?

            – Radoslav Hubenov
            Mar 28 at 13:49






          • 1





            If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

            – Gary Russell
            Mar 28 at 13:54






          • 1





            If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

            – Gary Russell
            Mar 28 at 14:33


















          1
















          Queue channel takes Queue as a constructor parameter public QueueChannel(Queue<Message<?>> queue) and spring-integration DSL provides public static QueueChannelSpec queue(Queue<Message<?>> queue). So you can use Collections.asLifoQueue(..) as an argument to the above factory method to get the behavior you want.






          share|improve this answer



























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398745%2fhow-to-create-a-lifo-queue-channel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1
















            It sounds like you don't really want LIFO, you just want the latest for a given condition.



            But, regardless, Queue is a pretty simple interface; it only has a handful of methods and the QueueChannel only uses poll(), offer() and size().



            So it should be simple to create a custom queue, e.g. based on a thread-safe ConcurrentHashMap<String, Message<?>> with the key being your condition.






            share|improve this answer

























            • How would I have to proceed so that the older messages with the same userId in the queue are discarded?

              – Radoslav Hubenov
              Mar 28 at 13:49






            • 1





              If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

              – Gary Russell
              Mar 28 at 13:54






            • 1





              If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

              – Gary Russell
              Mar 28 at 14:33















            1
















            It sounds like you don't really want LIFO, you just want the latest for a given condition.



            But, regardless, Queue is a pretty simple interface; it only has a handful of methods and the QueueChannel only uses poll(), offer() and size().



            So it should be simple to create a custom queue, e.g. based on a thread-safe ConcurrentHashMap<String, Message<?>> with the key being your condition.






            share|improve this answer

























            • How would I have to proceed so that the older messages with the same userId in the queue are discarded?

              – Radoslav Hubenov
              Mar 28 at 13:49






            • 1





              If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

              – Gary Russell
              Mar 28 at 13:54






            • 1





              If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

              – Gary Russell
              Mar 28 at 14:33













            1














            1










            1









            It sounds like you don't really want LIFO, you just want the latest for a given condition.



            But, regardless, Queue is a pretty simple interface; it only has a handful of methods and the QueueChannel only uses poll(), offer() and size().



            So it should be simple to create a custom queue, e.g. based on a thread-safe ConcurrentHashMap<String, Message<?>> with the key being your condition.






            share|improve this answer













            It sounds like you don't really want LIFO, you just want the latest for a given condition.



            But, regardless, Queue is a pretty simple interface; it only has a handful of methods and the QueueChannel only uses poll(), offer() and size().



            So it should be simple to create a custom queue, e.g. based on a thread-safe ConcurrentHashMap<String, Message<?>> with the key being your condition.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 28 at 13:40









            Gary RussellGary Russell

            94.5k9 gold badges59 silver badges86 bronze badges




            94.5k9 gold badges59 silver badges86 bronze badges















            • How would I have to proceed so that the older messages with the same userId in the queue are discarded?

              – Radoslav Hubenov
              Mar 28 at 13:49






            • 1





              If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

              – Gary Russell
              Mar 28 at 13:54






            • 1





              If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

              – Gary Russell
              Mar 28 at 14:33

















            • How would I have to proceed so that the older messages with the same userId in the queue are discarded?

              – Radoslav Hubenov
              Mar 28 at 13:49






            • 1





              If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

              – Gary Russell
              Mar 28 at 13:54






            • 1





              If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

              – Gary Russell
              Mar 28 at 14:33
















            How would I have to proceed so that the older messages with the same userId in the queue are discarded?

            – Radoslav Hubenov
            Mar 28 at 13:49





            How would I have to proceed so that the older messages with the same userId in the queue are discarded?

            – Radoslav Hubenov
            Mar 28 at 13:49




            1




            1





            If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

            – Gary Russell
            Mar 28 at 13:54





            If it's based on a Map, new entries with the same key will be replaced and it will only have the last one.

            – Gary Russell
            Mar 28 at 13:54




            1




            1





            If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

            – Gary Russell
            Mar 28 at 14:33





            If you want to retain order for different userIds, you can use a combination of a LinkedHashSet<String> for the userIds and Map<String, Message<?>> for the messages. The LinkedHashSet retains the original order when an element is replaced.

            – Gary Russell
            Mar 28 at 14:33













            1
















            Queue channel takes Queue as a constructor parameter public QueueChannel(Queue<Message<?>> queue) and spring-integration DSL provides public static QueueChannelSpec queue(Queue<Message<?>> queue). So you can use Collections.asLifoQueue(..) as an argument to the above factory method to get the behavior you want.






            share|improve this answer





























              1
















              Queue channel takes Queue as a constructor parameter public QueueChannel(Queue<Message<?>> queue) and spring-integration DSL provides public static QueueChannelSpec queue(Queue<Message<?>> queue). So you can use Collections.asLifoQueue(..) as an argument to the above factory method to get the behavior you want.






              share|improve this answer



























                1














                1










                1









                Queue channel takes Queue as a constructor parameter public QueueChannel(Queue<Message<?>> queue) and spring-integration DSL provides public static QueueChannelSpec queue(Queue<Message<?>> queue). So you can use Collections.asLifoQueue(..) as an argument to the above factory method to get the behavior you want.






                share|improve this answer













                Queue channel takes Queue as a constructor parameter public QueueChannel(Queue<Message<?>> queue) and spring-integration DSL provides public static QueueChannelSpec queue(Queue<Message<?>> queue). So you can use Collections.asLifoQueue(..) as an argument to the above factory method to get the behavior you want.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 13:42









                Oleg ZhurakouskyOleg Zhurakousky

                2,3908 silver badges10 bronze badges




                2,3908 silver badges10 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398745%2fhow-to-create-a-lifo-queue-channel%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해