Forum Discussion

qazwsx's avatar
qazwsx
Occasional Contributor
6 years ago
Solved

Dynamically set JMS Properties from groovy code

Dears,   Can you please tell me if there is any way to set JMS Property from groovy code? I tried different ways to find a solution but unfortunately, nothing is working. I can't use f...
  • nmrao's avatar
    nmrao
    6 years ago

    qazwsx 

     

    Ok. Try to put below code in SubmitListener.beforeSubmit

     

     

    import com.eviware.soapui.config.JMSPropertyConfig
    
    //Assign your data from datasource into map below - have your logic; otherwise try with fixed data
    def map = [a: 'one', b:'two']
    if ('JMSRequestReply' == submit.request.name) {
        def existingProperties = submit.request.getJMSPropertiesConfig().getJMSProperties()
    
       def newList = new ArrayList<JMSPropertyConfig>()
       map.each { key, value ->
    	def jmsPropertyConfig = JMSPropertyConfig.Factory.newInstance()
    	jmsPropertyConfig.setName(key)
    	jmsPropertyConfig.setValue(value)
    	newList.add(jmsPropertyConfig)
       }
               
       existingProperties.clear()
       existingProperties.addAll(newList)
    
    }