[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-03-02 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/2458


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-28 Thread mosermw
Github user mosermw commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r171354166
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ConsumeJMS.java
 ---
@@ -136,9 +155,16 @@
 relationships = Collections.unmodifiableSet(_relationships);
 }
 
+@OnScheduled
--- End diff --

Very good point, and I like the customValidate approach.  I'll make the 
change.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-28 Thread markap14
Github user markap14 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r171352969
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ConsumeJMS.java
 ---
@@ -136,9 +155,16 @@
 relationships = Collections.unmodifiableSet(_relationships);
 }
 
+@OnScheduled
--- End diff --

@mosermw thanks for the explanation! Makes sense. I would recommend 
reconsidering where it is implemented, though. Would look at either creating a 
new Validator in StandardValidators that allows EL without FlowFile attributes 
and evaluates that before validating the result, or otherwise just removing the 
validator all together and implementing it in customValidate... I would just 
prefer to see this done as part of the validation, rather than when the user 
attempts to start the processor. Make sense?


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-28 Thread mosermw
Github user mosermw commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r171296519
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ConsumeJMS.java
 ---
@@ -136,9 +155,16 @@
 relationships = Collections.unmodifiableSet(_relationships);
 }
 
+@OnScheduled
--- End diff --

Thanks for looking at this @markap14.  The CHARACTER_SET_VALIDATOR 
essentially says a property value is valid if an EL expression returns a 
String.  If someone sets it to ${system.charset} and that environment variable 
is set to "FOO", for example, then when ConsumeJMS receives a TextMessage it 
will throw an UnsupportedCharsetException at runtime.  I thought I would 
include this method to give earlier warning.  PublishJMS doesn't need this 
check, because the charset could be set in a flowfile attribute, and 
UnsupportedCharsetException would just cause the flowfile to go to 'failure'.  
If you still think the method is unnecessary, though, let me know and I can 
remove it.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-28 Thread markap14
Github user markap14 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r171283791
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ConsumeJMS.java
 ---
@@ -136,9 +155,16 @@
 relationships = Collections.unmodifiableSet(_relationships);
 }
 
+@OnScheduled
--- End diff --

Hey @mosermw is this something we need to do? We have the Character Set 
Validator already in place so it should never get this far if it's not valid.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread mosermw
Github user mosermw commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167258538
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

And now that I look closer, I see there is already a precedent for this in 
the code, such as in LogAttribute.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread mosermw
Github user mosermw commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167255119
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

Oh, I didn't think about that approach!  I like it.  I'll make the changes.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread devriesb
Github user devriesb commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167252827
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

i'm not sure if this is a helpful "middle ground" suggestion or not, but 
you could add a charset property that itself defaults to 
Charset.defaultCharset().  That way the out of the box behavior uses the 
charset specified for the jvm, but can be overridden on a per processor basis 
if needed.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread anderson900
Github user anderson900 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167245934
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

Shouldn't we rely on the charset specified for the JVM in boostrap.conf, 
which would become the default charset?


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread mosermw
Github user mosermw commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167244022
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

I did think about this, and I chose this approach on purpose.  It's kind of 
the whole point of setting a default Charset in your JVM, to produce results 
that are specific to your desired environment.  Is this not right?


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-09 Thread markap14
Github user markap14 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2458#discussion_r167240898
  
--- Diff: 
nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/PublishJMS.java
 ---
@@ -131,4 +143,10 @@ protected JMSPublisher 
finishBuildingJmsWorker(CachingConnectionFactory connecti
 session.read(flowFile, in -> StreamUtils.fillBuffer(in, 
messageContent, true));
 return messageContent;
 }
+
+private String extractTextMessageBody(FlowFile flowFile, 
ProcessSession session) {
+final StringWriter writer = new StringWriter();
+session.read(flowFile, in -> IOUtils.copy(in, writer, 
Charset.defaultCharset()));
--- End diff --

We probably want to expose the character set as a property. At a minimum, 
we should be explicit in defining which character set would be used (UTF-8 
perhaps) instead of relying on the default charset, as this would produce 
different results from environment to environment.


---


[GitHub] nifi pull request #2458: NIFI-2630 Allow PublishJMS to send TextMessages

2018-02-08 Thread mosermw
GitHub user mosermw opened a pull request:

https://github.com/apache/nifi/pull/2458

NIFI-2630 Allow PublishJMS to send TextMessages

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced 
 in the commit message?

- [x] Does your PR title start with NIFI- where  is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.

- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [x] Is your initial contribution a single, squashed commit?

### For code changes:
- [x] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
- [x] Have you written or updated unit tests to verify your changes?
- [ ] 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.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mosermw/nifi NIFI-2630

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/2458.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2458


commit 441784ef8a7a3b9354cd474de495ffdbfd75ee67
Author: Mike Moser 
Date:   2018-02-07T16:00:57Z

NIFI-2630 Allow PublishJMS to send TextMessages




---