Bug 52936

Summary: JMS Publisher : Support sending of JMS Object Messages
Product: JMeter - Now in Github Reporter: Miel Donkers <miel.donkers>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: enhancement CC: p.mouawad
Priority: P2    
Version: 2.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on: 53129    
Bug Blocks:    
Attachments: Patch file for Object Message enhancement
Patch for loading object and deserialize with XStream
Supplementary patch to get XStream working
Patch for loading object and deserialize with XStream. Load from file or from text-area
Sample Plan used for testing, it serializes JMeter Thread Group

Description Miel Donkers 2012-03-18 11:07:22 UTC
Created attachment 28484 [details]
Patch file for Object Message enhancement

Hi,

The current implementation of JMS Publisher does not support sending of Object Messages, simply an exception is thrown.

The supplied patch fixes this issue and allows the loading of a serialized object from file, and send it as the body of an JMS Object Message.

Some small code cleanup is also included, but provides no additional functionality.
Comment 1 Philippe Mouawad 2012-03-18 21:08:09 UTC
Hello,
Thanks for your patch submission.
Reviewing it I have a little issue with it, currently how do you make the content variable ?
Wouldn't be a better solution to unmarshall the java Object from an XML structure using XStream, which would make it easier to variabilize the content ?
Comment 2 Miel Donkers 2012-03-19 08:07:51 UTC
Thanks for your feedback. To be honest I did not think of this solution.
I will change the implementation to use XStream. And also make sure that the XML can be pasted in the text-field and as such the Object Message can be sent.
After the changes are made I will supply a new patch.
Comment 3 Miel Donkers 2012-03-27 15:24:24 UTC
Created attachment 28510 [details]
Patch for loading object and deserialize with XStream

Refactored the previous solution. Now uses XStream to load an (XML) object, which is deserialized so it can be send as JMS Object Message body.
Comment 4 Miel Donkers 2012-03-27 15:34:29 UTC
Hi,

I updated the solution to use XStream to deserialize an object from XML.

There is one problem however; to correctly deserialize our objects (which include Joda time) we need the latest version of XStream library (1.4.2).
I already updated this dependency version. However between 1.3.x and 1.4.x a change was made to use dynamic loading of a XML Pull Parser. For this, XStream expects a XMLPullParserFactory to be on its path. So still the supplied code and the JMeter test set is failing.

The XMLPullParserFactory is not included in the Xpp3 dependency. There are two solutions;
- Either tell XStream to explicitly use the Xpp3Driver
- Put a dependency on the path including the XMLPullParserFactory. For example xmlpull-1.1.3.1.jar or kXML2

The first solution introduces quite some work, but for the second solution I don't know which library would be preferred.

Please let me know if there are other questions.

I'll make a separate patch to also be able to paste the XML object into the text field and send it as object as such.
Comment 5 Miel Donkers 2012-04-02 14:04:33 UTC
Created attachment 28528 [details]
Supplementary patch to get XStream working

Patch file adds XMLPull library to the project, so that XStream works again.
The newer version of XStream tries to use a XMLPullFactory, which was not included.
Comment 6 Miel Donkers 2012-04-02 14:05:28 UTC
See patches. Together these should implement the requested enhancement.
Comment 7 Philippe Mouawad 2012-04-22 19:59:10 UTC
Thanks, Applied partly patch for XStream.
Comment 8 Philippe Mouawad 2012-04-24 21:41:59 UTC
I have reviewed the patch and there are still some things to change.

My main concern is that as implemented in fact it loads Java Object  as XML from file.
This is an issue to variabilize data as data loaded from file cannot be variabilized (see https://issues.apache.org/bugzilla/show_bug.cgi?id=15468).

So it would be better if Object serialized in XML could be loaded from TextArea and so stored in Test Plan. This would ease a lot the variabilization and so make patch more useful.
Another concern would be some tooling to serialize the Object to XML with XStream from JMeter GUI, cause with current proposed patch user must write some code in Java to serialize.
Comment 9 Sebb 2012-04-24 23:35:42 UTC
Seems to me it would be best if the object could be derived either from a file or from the screen.
Comment 10 Philippe Mouawad 2012-04-25 06:17:39 UTC
Hello,
What do you mean dérived from screen ? 
What i havé in mind is to use current  textarea
And if object is sélected as type then déserialize from XML .
This would allow easy variabilization of object properties.
Another way would be to enable getting an object from jmeter context
(so name of object should be input) and a beanshell sampler would havé
Set it before.
Comment 11 Sebb 2012-04-25 08:56:47 UTC
(In reply to comment #10)
> Hello,
> What do you mean dérived from screen ? 
> What i havé in mind is to use current  textarea

That's what I meant.

> And if object is sélected as type then déserialize from XML .
> This would allow easy variabilization of object properties.

Yes.

> Another way would be to enable getting an object from jmeter context
> (so name of object should be input) and a beanshell sampler would havé
> Set it before.

But neither is good for large (fixed) objects, which is why it would be useful to be able to read the XML from a file.
Comment 12 Miel Donkers 2012-04-25 09:33:04 UTC
Hi,

After this patch was committed, I also wanted to write a patch to (as is suggested in the comments) to load XML from the text area. This would then correspond with existing functionality (load message content both from text area as well as a file). Because we need the 'loading from a file' and because of consistency, I therefore also propose to support both options.

I understand now that it would be better to combine the two into one single patch.   Please expect this patch here in the next couple of days...

To serialize an object into XML from within the JMeter GUI I don't yet have a solution / proposal. We are using our own 'tool' which we created specifically for this task. This tool could be modified to be included into JMeter.
Is there already similar functionality in JMeter for a different protocol? We could then mimic the look&feel and behaviour.
Comment 13 Miel Donkers 2012-05-03 09:35:42 UTC
Created attachment 28713 [details]
Patch for loading object and deserialize with XStream. Load from file or from text-area

This new patch replaces the previous one about object loading.
It is now also possible to copy-paste XML into the JMeter text-area, which will be transformed by XStream and used for the JMS Object Message body.
Comment 14 Philippe Mouawad 2012-05-03 13:50:42 UTC
Date: Thu May  3 13:49:55 2012
New Revision: 1333460

URL: http://svn.apache.org/viewvc?rev=1333460&view=rev
Log:
Bug 52936 - JMS Publisher : Support sending of JMS Object Messages

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages_es.properties
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages_pt_BR.properties
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages_tr.properties
   jmeter/trunk/src/core/org/apache/jmeter/resources/messages_zh_TW.properties
   jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/control/gui/JMSPublisherGui.java
   jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/PublisherSampler.java
   jmeter/trunk/xdocs/changes.xml
   jmeter/trunk/xdocs/usermanual/component_reference.xml
Comment 15 Philippe Mouawad 2012-05-03 13:52:49 UTC
Thanks for the patch.
Applied with following changes:
- Removed popup that triggered when TextArea as source was select and Object Type Radio was selected
- Removed useless messages from resources
- Modified label of Text area as its content can also be used by Object Messages
- Changed instance methods to static
- Updated component_reference.xml
Comment 16 Philippe Mouawad 2012-05-03 13:54:37 UTC
Created attachment 28715 [details]
Sample Plan used for testing, it serializes JMeter Thread Group

Code used for serialization:

public class SerializeWithXStream {

    public static void main(String[] args) {
        ThreadGroup threadGroup = new ThreadGroup();
        threadGroup.setComment("comment");
        threadGroup.setDelay(123);
        threadGroup.setDuration(456);
        threadGroup.setName("TG-1");
        threadGroup.setNumThreads(5);
        threadGroup.setRampUp(600);
        threadGroup.setStartTime(111111111);
        XStream xstream = new XStream();
        String xml = xstream.toXML(threadGroup);
        System.out.println(xml);
    }
}
Comment 17 The ASF infrastructure team 2022-09-24 20:37:49 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2784