{"id":62056,"date":"2016-11-22T22:00:37","date_gmt":"2016-11-22T20:00:37","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=62056"},"modified":"2016-11-22T12:15:33","modified_gmt":"2016-11-22T10:15:33","slug":"spring-integration-mongodb-adapters-java-dsl","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html","title":{"rendered":"Spring Integration MongoDB adapters with Java DSL"},"content":{"rendered":"<h2>1 Introduction<\/h2>\n<p>This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are going to configure inbound and outbound MongoDB channel adapters using the Java DSL configuration extension. As an example, we are going to build an application to allow you to write orders to a MongoDB store, and then retrieve them for processing.<\/p>\n<p>The application flow can be split in two parts:<\/p>\n<ul>\n<li>New orders are sent to the messaging system, where they will be converted to actual products and then stored to MongoDB.<\/li>\n<\/ul>\n<ul>\n<li>On the other hand, another component is continuously polling the database and processing any new product it finds.<\/li>\n<\/ul>\n<p>The source code can be found in my\u00a0<a href=\"https:\/\/github.com\/xpadro\/spring-integration\/tree\/master\/mongodb\/mongo-basic\" target=\"_blank\">Spring Integration repository<\/a>.<\/p>\n<h2>2 MessagingGateway &#8211; Entering the messaging system<\/h2>\n<p>Our application does not know anything about the messaging system. In fact, it will just create new orders and send them to an interface (OrderService):<\/p>\n<pre class=\"brush:java\">@SpringBootApplication\r\n@EnableIntegration\r\npublic class MongodbBasicApplication {\r\n    \r\n    public static void main(String[] args) {\r\n        ConfigurableApplicationContext context = SpringApplication.run(MongodbBasicApplication.class, args);\r\n        new MongodbBasicApplication().start(context);\r\n    }\r\n    \r\n    public void start(ConfigurableApplicationContext context) {\r\n        resetDatabase(context);\r\n        \r\n        Order order1 = new Order(\"1\", true);\r\n        Order order2 = new Order(\"2\", false);\r\n        Order order3 = new Order(\"3\", true);\r\n        \r\n        InfrastructureConfiguration.OrderService orderService = context.getBean(InfrastructureConfiguration.OrderService.class);\r\n        \r\n        orderService.order(order1);\r\n        orderService.order(order2);\r\n        orderService.order(order3);\r\n    }\r\n    \r\n    private void resetDatabase(ConfigurableApplicationContext context) {\r\n        ProductRepository productRepository = context.getBean(ProductRepository.class);\r\n        productRepository.deleteAll();\r\n    }\r\n}<\/pre>\n<p>Taking an initial look at the configuration, we can see that the OrderService is actually a messaging gateway.<\/p>\n<pre class=\"brush:java\">@Configuration\r\n@ComponentScan(\"xpadro.spring.integration.endpoint\")\r\n@IntegrationComponentScan(\"xpadro.spring.integration.mongodb\")\r\npublic class InfrastructureConfiguration {\r\n\r\n    @MessagingGateway\r\n    public interface OrderService {\r\n\r\n        @Gateway(requestChannel = \"sendOrder.input\")\r\n        void order(Order order);\r\n    }\r\n    \r\n    ...\r\n}<\/pre>\n<p>Any order sent to the order method will be introduced to the messaging system as a Message&lt;Order&gt; through the &#8216;sendOrder.input&#8217; direct channel.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2>3 First part &#8211; processing orders<\/h2>\n<p>The first part of the Spring Integration messaging flow is composed by the following components:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_firstPart.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-62087\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_firstPart.png\" alt=\"flow_firstpart\" width=\"650\" height=\"102\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_firstPart.png 650w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_firstPart-300x47.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p>We use a lambda to create an IntegrationFlow definition, which registers a DirectChannel as its input channel. The name of the input channel is resolved as &#8216;beanName + .input&#8217;. Hence, the name is the one we specified in the gateway: &#8216;sendOrder.input&#8217;<\/p>\n<pre class=\"brush:java\">@Bean\r\n@Autowired\r\npublic IntegrationFlow sendOrder(MongoDbFactory mongo) {\r\n    return f -&gt; f\r\n        .transform(Transformers.converter(orderToProductConverter()))\r\n        .handle(mongoOutboundAdapter(mongo));\r\n}<\/pre>\n<p>The\u00a0first thing the flow does when receiving a new order is use a transformer to convert the order into a product. To register a transformer we can use the Transformers factory provided by the DSL API. Here, we have different possibilities. The one I chose is using a\u00a0<a href=\"https:\/\/docs.spring.io\/spring-integration\/api\/org\/springframework\/integration\/transformer\/PayloadTypeConvertingTransformer.html\" target=\"_blank\">PayloadTypeConvertingTransformer<\/a>, which delegates to a converter the transformation of the payload into an object.<\/p>\n<pre class=\"brush:java\">public class OrderToProductConverter implements Converter&lt;Order, Product&gt; {\r\n\r\n    @Override\r\n    public Product convert(Order order) {\r\n        return new Product(order.getId(), order.isPremium());\r\n    }\r\n}<\/pre>\n<p>The next step in the orders flow is to store the newly created product to the database. Here, we use a MongoDB outbound adapter:<\/p>\n<pre class=\"brush:java\">@Bean\r\n@Autowired\r\npublic MessageHandler mongoOutboundAdapter(MongoDbFactory mongo) {\r\n    MongoDbStoringMessageHandler mongoHandler = new MongoDbStoringMessageHandler(mongo);\r\n    mongoHandler.setCollectionNameExpression(new LiteralExpression(\"product\"));\r\n    return mongoHandler;\r\n}<\/pre>\n<p>If you wonder what the message handler is actually doing internally, it uses a mongoTemplate to save the entity:<\/p>\n<pre class=\"brush:java\">@Override\r\nprotected void handleMessageInternal(Message&lt;?&gt; message) throws Exception {\r\n    String collectionName = this.collectionNameExpression.getValue(this.evaluationContext, message, String.class);\r\n    Object payload = message.getPayload();\r\n    \r\n    this.mongoTemplate.save(payload, collectionName);\r\n}<\/pre>\n<h2>4 Second part &#8211; processing products<\/h2>\n<p>In this second part we have another integration flow for processing products:<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_secondPart.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-62088\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_secondPart.png\" alt=\"flow_secondpart\" width=\"650\" height=\"243\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_secondPart.png 650w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2016\/11\/flow_secondPart-300x112.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p>In order to retrieve previously created products, we have defined an inbound channel adapter which will continuously be polling the MongoDB database:<\/p>\n<pre class=\"brush:java\">@Bean\r\n@Autowired\r\npublic IntegrationFlow processProduct(MongoDbFactory mongo) {\r\n    return IntegrationFlows.from(mongoMessageSource(mongo), c -&gt; c.poller(Pollers.fixedDelay(3, TimeUnit.SECONDS)))\r\n        .route(Product::isPremium, this::routeProducts)\r\n        .handle(mongoOutboundAdapter(mongo))\r\n        .get();\r\n}<\/pre>\n<p>The MongoDB inbound channel adapter is the one responsible for polling products from the database. We specify the query in the constructor. In this case, we poll one non processed product each time:<\/p>\n<pre class=\"brush:java\">@Bean\r\n@Autowired\r\npublic MessageSource&lt;Object&gt; mongoMessageSource(MongoDbFactory mongo) {\r\n    MongoDbMessageSource messageSource = new MongoDbMessageSource(mongo, new LiteralExpression(\"{'processed' : false}\"));\r\n    messageSource.setExpectSingleResult(true);\r\n    messageSource.setEntityClass(Product.class);\r\n    messageSource.setCollectionNameExpression(new LiteralExpression(\"product\"));\r\n    \r\n    return messageSource;\r\n}<\/pre>\n<p>The router definition shows how the product is sent to a different service activator method depending on the &#8216;premium&#8217; field:<\/p>\n<pre class=\"brush:java\">private RouterSpec&lt;Boolean, MethodInvokingRouter&gt; routeProducts(RouterSpec&lt;Boolean, MethodInvokingRouter&gt; mapping) {\r\n    return mapping\r\n        .subFlowMapping(true, sf -&gt; sf.handle(productProcessor(), \"fastProcess\"))\r\n        .subFlowMapping(false, sf -&gt; sf.handle(productProcessor(), \"process\"));\r\n}<\/pre>\n<p>As a service activator, we have a simple bean which logs a message and sets the product as processed. Then, it will return the product so it can be handled by the next endpoint in the flow.<\/p>\n<pre class=\"brush:java\">public class ProductProcessor {\r\n\r\n    public Product process(Product product) {\r\n        return doProcess(product, String.format(\"Processing product %s\", product.getId()));\r\n    }\r\n\r\n    public Product fastProcess(Product product) {\r\n        return doProcess(product, String.format(\"Fast processing product %s\", product.getId()));\r\n    }\r\n\r\n    private Product doProcess(Product product, String message) {\r\n        System.out.println(message);\r\n        product.setProcessed(true);\r\n        return product;\r\n    }\r\n}<\/pre>\n<p>The reason for setting the product as processed is because the next step is to update its status in the database in order to not poll it again. We save it by redirecting the flow to the mongoDb outbound channel adapter again.<\/p>\n<h2>5 Conclusion<\/h2>\n<p>You have seen what endpoints you do have to use in order to interact with a MongoDB database using Spring Integration. The outbound channel adapter passively saves products to the database, while the inbound channel adapter actively polls the database to retrieve new products.<\/p>\n<p>If you found this post useful, please share it or star my repository. I appreciate it :)<\/p>\n<p>I&#8217;m publishing my new posts on Google plus and Twitter. Follow me if you want to be updated with new content.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/xpadro.blogspot.com\/2016\/11\/spring-integration-mongodb-adapters.html\">Spring Integration MongoDB adapters with Java DSL<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/join-us\/jcg\/\">JCG partner<\/a> Xavier Padro at the <a href=\"http:\/\/xpadro.blogspot.com\/\">Xavier Padr\u00f3&#8217;s Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are going to configure inbound and outbound MongoDB channel adapters using the Java DSL configuration extension. As an example, we are going to build an application to allow you to write &hellip;<\/p>\n","protected":false},"author":533,"featured_media":187,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[356,112,30,410],"class_list":["post-62056","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-dsl","tag-mongodb","tag-spring","tag-spring-integration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Integration MongoDB adapters with Java DSL - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Integration MongoDB adapters with Java DSL - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-22T20:00:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Xavier Padro\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/xavips\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Xavier Padro\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html\"},\"author\":{\"name\":\"Xavier Padro\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5443fbc8fb815652f181942d4622090d\"},\"headline\":\"Spring Integration MongoDB adapters with Java DSL\",\"datePublished\":\"2016-11-22T20:00:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html\"},\"wordCount\":648,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"keywords\":[\"DSL\",\"MongoDB\",\"Spring\",\"Spring Integration\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html\",\"name\":\"Spring Integration MongoDB adapters with Java DSL - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"datePublished\":\"2016-11-22T20:00:37+00:00\",\"description\":\"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/11\\\/spring-integration-mongodb-adapters-java-dsl.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Integration MongoDB adapters with Java DSL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/5443fbc8fb815652f181942d4622090d\",\"name\":\"Xavier Padro\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g\",\"caption\":\"Xavier Padro\"},\"description\":\"Xavier is a software developer working in a consulting firm based in Barcelona. He is specialized in web application development with experience in both frontend and backend. He is interested in everything related to Java and the Spring framework.\",\"sameAs\":[\"http:\\\/\\\/xpadro.blogspot.gr\\\/\",\"http:\\\/\\\/linkedin.com\\\/pub\\\/xavier-padro-sobrepera\\\/1a\\\/64\\\/3\\\/en\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/xavips\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/xavier-padro\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Integration MongoDB adapters with Java DSL - Java Code Geeks","description":"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html","og_locale":"en_US","og_type":"article","og_title":"Spring Integration MongoDB adapters with Java DSL - Java Code Geeks","og_description":"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are","og_url":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-11-22T20:00:37+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Xavier Padro","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/xavips","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Xavier Padro","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html"},"author":{"name":"Xavier Padro","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5443fbc8fb815652f181942d4622090d"},"headline":"Spring Integration MongoDB adapters with Java DSL","datePublished":"2016-11-22T20:00:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html"},"wordCount":648,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","keywords":["DSL","MongoDB","Spring","Spring Integration"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html","url":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html","name":"Spring Integration MongoDB adapters with Java DSL - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","datePublished":"2016-11-22T20:00:37+00:00","description":"1 Introduction This post explains how to save and retrieve entities from a MongoDB database using Spring Integration. In order to accomplish that, we are","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2016\/11\/spring-integration-mongodb-adapters-java-dsl.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Integration MongoDB adapters with Java DSL"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/5443fbc8fb815652f181942d4622090d","name":"Xavier Padro","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bbf0579a188773b88762d54dadc779b2cd17ddb261d809956ed55d8569bd7ca2?s=96&d=mm&r=g","caption":"Xavier Padro"},"description":"Xavier is a software developer working in a consulting firm based in Barcelona. He is specialized in web application development with experience in both frontend and backend. He is interested in everything related to Java and the Spring framework.","sameAs":["http:\/\/xpadro.blogspot.gr\/","http:\/\/linkedin.com\/pub\/xavier-padro-sobrepera\/1a\/64\/3\/en","https:\/\/x.com\/https:\/\/twitter.com\/xavips"],"url":"https:\/\/www.javacodegeeks.com\/author\/xavier-padro"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/62056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/533"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=62056"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/62056\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/187"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=62056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=62056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=62056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}