Skip to content

Instantly share code, notes, and snippets.

@welshstew
Created September 12, 2014 04:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save welshstew/45aa6f42f847fce25593 to your computer and use it in GitHub Desktop.
Save welshstew/45aa6f42f847fce25593 to your computer and use it in GitHub Desktop.
send jms messages to activemq with a neat groovy script
@Grab(group='org.apache.activemq',module = 'activemq-all', version='5.8.0')
import org.apache.activemq.ActiveMQConnectionFactory
import javax.jms.*
def brokerUrl = 'tcp://localhost:61616'
def queue = 'the.soapoverjms.service'
def soapAction = 'urn:sixtree:soapoverjms:dosomething'
def reader = new BufferedReader(new InputStreamReader(System.in))
new ActiveMQConnectionFactory(brokerURL: brokerUrl).createConnection().with {
start()
createSession(false, Session.AUTO_ACKNOWLEDGE).with {
def message = createTextMessage(reader.text)
message.with {
jMSDeliveryMode = DeliveryMode.NON_PERSISTENT
jMSReplyTo = createTemporaryQueue()
jMSCorrelationID = UUID.randomUUID().toString()
setStringProperty('SOAPJMS_soapAction', soapAction)
}
createProducer().send(createQueue(queue), message)
}
close()
}
//run with
groovy jms.groovy < ~/Downloads/request.xml
@prasadbasutkar
Copy link

its giving unable to resolve dependency issue , we have our own artifactory

@welshstew
Copy link
Author

@prasadbasutkar
Copy link

@GrabResolver(name='artifactory', root='<own_maven_artifactory_repo_url')
@grab(group='org.apache.activemq',module = 'activemq-all', version='5.8.0')

still getting below error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: org.apache.activemq#activemq-all;5.8.0: not found]

java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: org.apache.activemq#activemq-all;5.8.0: not found]

@welshstew
Copy link
Author

You may not have that dependency available - check your artifactory to see what activemq-all.jar artifacts are available there

@prasadbasutkar
Copy link

prasadbasutkar commented Mar 22, 2021

Index of repo/org/apache/activemq/activemq-all/5.8.0
Name Last modified Size
../
activemq-all-5.8.0-sources.jar-> - -
activemq-all-5.8.0-sources.jar.asc-> - -
activemq-all-5.8.0.jar 06-Feb-2013 16:32 5.56 MB
activemq-all-5.8.0.jar.asc-> - -
activemq-all-5.8.0.pom 06-Feb-2013 16:33 4.34 KB
activemq-all-5.8.0.pom.asc-> - -
Artifactory/6.16.0 Server at

@welshstew
Copy link
Author

Have a read of: https://stackoverflow.com/questions/16871792/groovy-grab-download-failed
are you able to resolve with grape?

grape -V resolve org.apache.activemq activemq-all 5.8.0

@prasadbasutkar
Copy link

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/nfs/production/extsrv2/projects/local_work/wp-05/dev2/tools/groovy/lib/groovy-2.5.8.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
:: resolving dependencies :: caller#all-caller;working05
confs: [default]
validate = false
refresh = false
resolving dependencies for configuration 'default'
== resolving dependencies for caller#all-caller;working05 [default]
== resolving dependencies caller#all-caller;working05->org.apache.activemq#activemq-all;5.8.0 [default->default]
downloadGrapes: Checking cache for: dependency: org.apache.activemq#activemq-all;5.8.0 {default=[default]}
tried http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.pom
tried http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.jar
artifactory: no ivy file nor artifact found for org.apache.activemq#activemq-all;5.8.0
WARN: module not found: org.apache.activemq#activemq-all;5.8.0
WARN: ==== artifactory: tried
WARN: http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.pom
WARN: -- artifact org.apache.activemq#activemq-all;5.8.0!activemq-all.jar:
WARN: http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.jar
resolved ivy file produced in cache
:: downloading artifacts ::
resolve done (62ms resolve - 0ms download)

:: problems summary ::
:::: WARNINGS
module not found: org.apache.activemq#activemq-all;5.8.0

==== artifactory: tried

  http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.pom

  -- artifact org.apache.activemq#activemq-all;5.8.0!activemq-all.jar:

  http://wwwint.ebi.ac.uk/wp/dev/artifactory/repo/org/apache/activemq/activemq-all/5.8.0/activemq-all-5.8.0.jar

:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
Error in resolve:
Error grabbing Grapes -- [unresolved dependency: org.apache.activemq#activemq-all;5.8.0: not found]
Perhaps the grape is not installed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment