You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/01/14 17:46:33 UTC

[GitHub] [nifi] tpalfy opened a new pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types

tpalfy opened a new pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types
URL: https://github.com/apache/nifi/pull/3987
 
 
   ConsumeJMS now supports ObjectMessage, MapMessage and StreamMessage types as well. Added optional ERROR_QUEUE property. Result flowfiles get a 'jms.messagetype' attribute that contains the incoming message type (TextMessage, BytesMessage, ObjectMessage, MapMessage or StreamMessage).
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [ ] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `master`)?
   
   - [ ] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [ ] Have you written or updated unit tests to verify your changes?
   - [ ] Have you verified that the full build is successful on both JDK 8 and JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] markap14 commented on issue #3987: NIFI-7015 - ConsumeJMS supports additional message types

Posted by GitBox <gi...@apache.org>.
markap14 commented on issue #3987: NIFI-7015 - ConsumeJMS supports additional message types
URL: https://github.com/apache/nifi/pull/3987#issuecomment-574397001
 
 
   Thanks @tpalfy, this is really nicely done! Was able to test it locally. I tried with TextMessage and BytesMessage, which we originally supported and all worked well. Tried with the new ObjectMessage and StreamMessage and these worked exactly as expected. MapMessage wrote out the JSON as intended. Also tried with an ActiveMQBlobMessage, since I was testing against ActiveMQ. As expected, it did receive the message but failed to process it, so it pushed it back to the error queue. All works exactly as expected. +1 will merge to master. Thanks again!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] markap14 merged pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types

Posted by GitBox <gi...@apache.org>.
markap14 merged pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types
URL: https://github.com/apache/nifi/pull/3987
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] tpalfy commented on a change in pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types

Posted by GitBox <gi...@apache.org>.
tpalfy commented on a change in pull request #3987: NIFI-7015 - ConsumeJMS supports additional message types
URL: https://github.com/apache/nifi/pull/3987#discussion_r366485252
 
 

 ##########
 File path: nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/processors/ConsumeJMSIT.java
 ##########
 @@ -65,11 +79,183 @@ public void validateSuccessfulConsumeAndTransferToSuccess() throws Exception {
             successFF.assertAttributeEquals("filename", "message.txt");
             successFF.assertAttributeExists("attribute_from_sender");
             successFF.assertAttributeEquals("attribute_from_sender", "some value");
+            successFF.assertAttributeExists("jms.messagetype");
+            successFF.assertAttributeEquals("jms.messagetype", "BytesMessage");
             successFF.assertContentEquals("Hey dude!".getBytes());
             String sourceDestination = successFF.getAttribute(ConsumeJMS.JMS_SOURCE_DESTINATION_NAME);
             assertNotNull(sourceDestination);
         } finally {
             ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
         }
     }
+
+    @Test
+    public void testValidateErrorQueueWhenDestinationIsTopicAndErrorQueueIsSet() throws Exception {
+        testValidateErrorQueue(ConsumeJMS.TOPIC, "errorQueue", false);
+    }
+
+    @Test
+    public void testValidateErrorQueueWhenDestinationIsTopicAndErrorQueueIsNotSet() throws Exception {
+        testValidateErrorQueue(ConsumeJMS.TOPIC, null, true);
+    }
+
+    @Test
+    public void testValidateErrorQueueWhenDestinationIsQueueAndErrorQueueIsSet() throws Exception {
+        testValidateErrorQueue(ConsumeJMS.QUEUE, "errorQueue", true);
+    }
+
+    @Test
+    public void testValidateErrorQueueWhenDestinationIsQueueAndErrorQueueIsNotSet() throws Exception {
+        testValidateErrorQueue(ConsumeJMS.QUEUE, null, true);
+    }
+
+    private void testValidateErrorQueue(String destinationType, String errorQueue, boolean expectedValid) throws Exception {
+        JmsTemplate jmsTemplate = CommonTest.buildJmsTemplateForDestination(false);
+
+        try {
+            TestRunner runner = TestRunners.newTestRunner(new ConsumeJMS());
+
+            JMSConnectionFactoryProviderDefinition cfService = mock(JMSConnectionFactoryProviderDefinition.class);
+            when(cfService.getIdentifier()).thenReturn("cfService");
+            when(cfService.getConnectionFactory()).thenReturn(jmsTemplate.getConnectionFactory());
+
+            runner.addControllerService("cfService", cfService);
+            runner.enableControllerService(cfService);
+
+            runner.setProperty(PublishJMS.CF_SERVICE, "cfService");
+            runner.setProperty(ConsumeJMS.DESTINATION, "destination");
+            runner.setProperty(ConsumeJMS.DESTINATION_TYPE, destinationType);
+            if (errorQueue != null) {
+                runner.setProperty(ConsumeJMS.ERROR_QUEUE, errorQueue);
+            }
+
+            if (expectedValid) {
+                runner.assertValid();
+            } else {
+                runner.assertNotValid();
+            }
+        } finally {
+            ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
+        }
+    }
+
+    @Test
+    public void testTextMessageTypeAttribute() throws Exception {
+        testMessageTypeAttribute(
+            "testTextMessage",
+            Session::createTextMessage,
+            TextMessage.class.getSimpleName()
+        );
+    }
+
+    @Test
+    public void testByteMessageTypeAttribute() throws Exception {
+        testMessageTypeAttribute(
+            "testByteMessage",
+            Session::createBytesMessage,
+            BytesMessage.class.getSimpleName()
+        );
+    }
+
+    @Test
+    public void testObjectMessageTypeAttribute() throws Exception {
+        String destinationName = "testObjectMessage";
 
 Review comment:
   Minor: Could be inlined similar to the other test methods.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services