@MessageMapping with Grails spring-websocket plugin

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

@MessageMapping with Grails spring-websocket plugin

grails_kotta
I am a Grails newbie and working on getting WebSockets working in an application. I got most of it working except I couldn't figure out how to pass parameters to the methods annotated with @MessageMapping.

This works:

<!-- language: lang-groovy -->
`class MyController{
    @MessageMapping(value="/start")
    protected void startProcess(){ }
}
`

What I need something like this to work:

<!-- language: lang-java -->
`
     @MessageMapping(value="/start/{file}")
     protected void startProcess(){ 
         String file = params.file
         //do somethig with the file...
     }
`
But it doesn't work. I have tried playing with UrlMappings.groovy, @PathVariable. I am pretty sure I am missing something simple. Any pointers?

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

zyro
hi,

check

http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-annotations

sth. like this should work:

@MessageMapping("/start/{file}")
protected void startProcess(@DestinationVariable String file){
     //do somethig with the file...
}

do not hesitate to post back if you are facing difficulties.

zyro

-------- Original Message  --------
Subject: @MessageMapping with Grails spring-websocket plugin
From: vgoud <[hidden email]>
To: [hidden email]
Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)

> I am a Grails newbie and working on getting WebSockets working in an
> application. I got most of it working except I couldn't figure out how
> to pass parameters to the methods annotated with @MessageMapping.
>
> This works:
>
> <!-- language: lang-groovy -->
> `class MyController{
>      @MessageMapping(value="/start")
>      protected void startProcess(){ }
> }
> `
>
> What I need something like this to work:
>
> <!-- language: lang-java -->
> `
>       @MessageMapping(value="/start/{file}")
>       protected void startProcess(){
>           String file = params.file
>           //do somethig with the file...
>       }
> `
> But it doesn't work. I have tried playing with UrlMappings.groovy,
> @PathVariable. I am pretty sure I am missing something simple. Any pointers?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Grails Dev Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> To post to this group, send email to [hidden email]
> <mailto:[hidden email]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com
> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/53DBE7C8.1080008%40zyro.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

grails_kotta
Thank you. That works, most of the time.. 
I am noticing a strange behavior where it seems to stop and start working randomly. I have spent a whole day trying to isolate the problem but no luck. It's been very frustrating. 


I see this in the log.

support.SimpAnnotationMethodMessageHandler Handling message, lookupDestination=/start/MY_FILE

support.SimpAnnotationMethodMessageHandler No matching method found


On Friday, August 1, 2014 3:17:33 PM UTC-4, zyro wrote:
hi,

check

<a href="http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-annotations" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.spring.io%2Fspring%2Fdocs%2F4.0.6.RELEASE%2Fspring-framework-reference%2Fhtmlsingle%2F%23websocket-stomp-handle-annotations\46sa\75D\46sntz\0751\46usg\75AFQjCNGFXsSk7bmCg8JXMCY7EgNlRq6Nuw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdocs.spring.io%2Fspring%2Fdocs%2F4.0.6.RELEASE%2Fspring-framework-reference%2Fhtmlsingle%2F%23websocket-stomp-handle-annotations\46sa\75D\46sntz\0751\46usg\75AFQjCNGFXsSk7bmCg8JXMCY7EgNlRq6Nuw';return true;">http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-annotations

sth. like this should work:

@MessageMapping("/start/{file}")
protected void startProcess(@DestinationVariable String file){
     //do somethig with the file...
}

do not hesitate to post back if you are facing difficulties.

zyro

-------- Original Message  --------
Subject: @MessageMapping with Grails spring-websocket plugin
From: vgoud <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">vg...@...>
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-de...@googlegroups.com
Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)

> I am a Grails newbie and working on getting WebSockets working in an
> application. I got most of it working except I couldn't figure out how
> to pass parameters to the methods annotated with @MessageMapping.
>
> This works:
>
> <!-- language: lang-groovy -->
> `class MyController{
>      @MessageMapping(value="/start")
>      protected void startProcess(){ }
> }
> `
>
> What I need something like this to work:
>
> <!-- language: lang-java -->
> `
>       @MessageMapping(value="/start/{file}")
>       protected void startProcess(){
>           String file = params.file
>           //do somethig with the file...
>       }
> `
> But it doesn't work. I have tried playing with UrlMappings.groovy,
> @PathVariable. I am pretty sure I am missing something simple. Any pointers?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Grails Dev Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-dev-discuss+unsubscribe@...
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-dev-discuss+unsubscribe@...>.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-de...@googlegroups.com
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cGjssg-fP2cJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">grails-de...@googlegroups.com>.
> To view this discussion on the web visit
> <a href="https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com';return true;" onclick="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com';return true;">https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com
> <<a href="https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8592-40832a026625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

zyro
may i ask what type the actual payload of your message is?
i think there are a few more options to achieve passing in that filename
which do not rely on dynamic destination mapping, e.g.
- the filename as the payload itself
- the filename as a part of a json object thats the payload
- the filename as a message header

zyro

-------- Original Message  --------
Subject: Re: @MessageMapping with Grails spring-websocket plugin
From: vgoud <[hidden email]>
To: [hidden email]
Date: Mon, 4 Aug 2014 14:53:18 -0700 (pdt)

> Thank you. That works, most of the time..
> I am noticing a strange behavior where it seems to stop and start
> working randomly. I have spent a whole day trying to isolate the problem
> but no luck. It's been very frustrating.
>
>
> I see this in the log.
>
> support.SimpAnnotationMethodMessageHandler Handling message,
> lookupDestination=/start/MY_FILE
>
> support.SimpAnnotationMethodMessageHandler No matching method found
>
>
> On Friday, August 1, 2014 3:17:33 PM UTC-4, zyro wrote:
>
>     hi,
>
>     check
>
>     http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-annotations
>     <http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-reference/htmlsingle/#websocket-stomp-handle-annotations>
>
>
>     sth. like this should work:
>
>     @MessageMapping("/start/{file}")
>     protected void startProcess(@DestinationVariable String file){
>           //do somethig with the file...
>     }
>
>     do not hesitate to post back if you are facing difficulties.
>
>     zyro
>
>     -------- Original Message  --------
>     Subject: @MessageMapping with Grails spring-websocket plugin
>     From: vgoud <[hidden email] <javascript:>>
>     To: [hidden email] <javascript:>
>     Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)
>
>      > I am a Grails newbie and working on getting WebSockets working in an
>      > application. I got most of it working except I couldn't figure
>     out how
>      > to pass parameters to the methods annotated with @MessageMapping.
>      >
>      > This works:
>      >
>      > <!-- language: lang-groovy -->
>      > `class MyController{
>      >      @MessageMapping(value="/start")
>      >      protected void startProcess(){ }
>      > }
>      > `
>      >
>      > What I need something like this to work:
>      >
>      > <!-- language: lang-java -->
>      > `
>      >       @MessageMapping(value="/start/{file}")
>      >       protected void startProcess(){
>      >           String file = params.file
>      >           //do somethig with the file...
>      >       }
>      > `
>      > But it doesn't work. I have tried playing with UrlMappings.groovy,
>      > @PathVariable. I am pretty sure I am missing something simple.
>     Any pointers?
>      >
>      > --
>      > You received this message because you are subscribed to the Google
>      > Groups "Grails Dev Discuss" group.
>      > To unsubscribe from this group and stop receiving emails from it,
>     send
>      > an email to [hidden email]
>     <javascript:>
>      > <mailto:[hidden email]
>     <javascript:>>.
>      > To post to this group, send email to
>     [hidden email] <javascript:>
>      > <mailto:[hidden email] <javascript:>>.
>      > To view this discussion on the web visit
>      >
>     https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com
>     <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Grails Dev Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> To post to this group, send email to [hidden email]
> <mailto:[hidden email]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8592-40832a026625%40googlegroups.com
> <https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8592-40832a026625%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/53E11493.9020509%40zyro.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

grails_kotta
It is an absolute path to a file. After playing around with regular
expressions without much luck, I am finally using this approach:

//file is URLencoded
@MessageMapping("/start?f={file}²)
protected def start(@DestinationVariable String file) {

        logFile = URLDecoder.decode(file, "UTF-8²);
}

I guess I could have put the file name in the payload and use it without
the encode and decode.
 


On 8/5/14, 1:29 PM, "zyro" <[hidden email]> wrote:

>may i ask what type the actual payload of your message is?
>i think there are a few more options to achieve passing in that filename
>which do not rely on dynamic destination mapping, e.g.
>- the filename as the payload itself
>- the filename as a part of a json object thats the payload
>- the filename as a message header
>
>zyro
>
>-------- Original Message  --------
>Subject: Re: @MessageMapping with Grails spring-websocket plugin
>From: vgoud <[hidden email]>
>To: [hidden email]
>Date: Mon, 4 Aug 2014 14:53:18 -0700 (pdt)
>
>> Thank you. That works, most of the time..
>> I am noticing a strange behavior where it seems to stop and start
>> working randomly. I have spent a whole day trying to isolate the problem
>> but no luck. It's been very frustrating.
>>
>>
>> I see this in the log.
>>
>> support.SimpAnnotationMethodMessageHandler Handling message,
>> lookupDestination=/start/MY_FILE
>>
>> support.SimpAnnotationMethodMessageHandler No matching method found
>>
>>
>> On Friday, August 1, 2014 3:17:33 PM UTC-4, zyro wrote:
>>
>>     hi,
>>
>>     check
>>
>>    
>>http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referenc
>>e/htmlsingle/#websocket-stomp-handle-annotations
>>    
>><http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referen
>>ce/htmlsingle/#websocket-stomp-handle-annotations>
>>
>>
>>     sth. like this should work:
>>
>>     @MessageMapping("/start/{file}")
>>     protected void startProcess(@DestinationVariable String file){
>>           //do somethig with the file...
>>     }
>>
>>     do not hesitate to post back if you are facing difficulties.
>>
>>     zyro
>>
>>     -------- Original Message  --------
>>     Subject: @MessageMapping with Grails spring-websocket plugin
>>     From: vgoud <[hidden email] <javascript:>>
>>     To: [hidden email] <javascript:>
>>     Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)
>>
>>      > I am a Grails newbie and working on getting WebSockets working
>>in an
>>      > application. I got most of it working except I couldn't figure
>>     out how
>>      > to pass parameters to the methods annotated with @MessageMapping.
>>      >
>>      > This works:
>>      >
>>      > <!-- language: lang-groovy -->
>>      > `class MyController{
>>      >      @MessageMapping(value="/start")
>>      >      protected void startProcess(){ }
>>      > }
>>      > `
>>      >
>>      > What I need something like this to work:
>>      >
>>      > <!-- language: lang-java -->
>>      > `
>>      >       @MessageMapping(value="/start/{file}")
>>      >       protected void startProcess(){
>>      >           String file = params.file
>>      >           //do somethig with the file...
>>      >       }
>>      > `
>>      > But it doesn't work. I have tried playing with
>>UrlMappings.groovy,
>>      > @PathVariable. I am pretty sure I am missing something simple.
>>     Any pointers?
>>      >
>>      > --
>>      > You received this message because you are subscribed to the
>>Google
>>      > Groups "Grails Dev Discuss" group.
>>      > To unsubscribe from this group and stop receiving emails from it,
>>     send
>>      > an email to [hidden email]
>>     <javascript:>
>>      > <mailto:[hidden email]
>>     <javascript:>>.
>>      > To post to this group, send email to
>>     [hidden email] <javascript:>
>>      > <mailto:[hidden email] <javascript:>>.
>>      > To view this discussion on the web visit
>>      >
>>    
>>https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-9
>>9bd-b03dc2c55ddd%40googlegroups.com
>>    
>><https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>99bd-b03dc2c55ddd%40googlegroups.com>
>>
>>      >
>>    
>><https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer
>>    
>><https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>>
>>.
>>
>>      > For more options, visit https://groups.google.com/d/optout
>>     <https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Grails Dev Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to [hidden email]
>> <mailto:[hidden email]>.
>> To post to this group, send email to [hidden email]
>> <mailto:[hidden email]>.
>> To view this discussion on the web visit
>>
>>https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8
>>592-40832a026625%40googlegroups.com
>>
>><https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-
>>8592-40832a026625%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>
>--
>You received this message because you are subscribed to the Google Groups
>"Grails Dev Discuss" group.
>To unsubscribe from this group and stop receiving emails from it, send an
>email to [hidden email].
>To post to this group, send email to [hidden email].
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/grails-dev-discuss/53E11493.9020509%40zy
>ro.net.
>For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/D007E63D.D2D%25vgoud%40ipkeys.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

zyro
yea if its only about the filename, i would opt for using the payload
itself.

@MessageMapping("/start")
protected void start(String file) {
     println file
}

just note that although it is just a string, it needs to be valid json
for the transport, i.e. use JSON.stringify(fileName) when sending from
javascript.

zyro

-------- Original Message  --------
Subject: Re: @MessageMapping with Grails spring-websocket plugin
From: Goud, Venkat <[hidden email]>
To: [hidden email]
<[hidden email]>
Date: Wed, 6 Aug 2014 18:09:40 +0000

> It is an absolute path to a file. After playing around with regular
> expressions without much luck, I am finally using this approach:
>
> //file is URLencoded
> @MessageMapping("/start?f={file}²)
> protected def start(@DestinationVariable String file) {
>
> logFile = URLDecoder.decode(file, "UTF-8²);
> }
>
> I guess I could have put the file name in the payload and use it without
> the encode and decode.
>
>
>
> On 8/5/14, 1:29 PM, "zyro" <[hidden email]> wrote:
>
>> may i ask what type the actual payload of your message is?
>> i think there are a few more options to achieve passing in that filename
>> which do not rely on dynamic destination mapping, e.g.
>> - the filename as the payload itself
>> - the filename as a part of a json object thats the payload
>> - the filename as a message header
>>
>> zyro
>>
>> -------- Original Message  --------
>> Subject: Re: @MessageMapping with Grails spring-websocket plugin
>> From: vgoud <[hidden email]>
>> To: [hidden email]
>> Date: Mon, 4 Aug 2014 14:53:18 -0700 (pdt)
>>
>>> Thank you. That works, most of the time..
>>> I am noticing a strange behavior where it seems to stop and start
>>> working randomly. I have spent a whole day trying to isolate the problem
>>> but no luck. It's been very frustrating.
>>>
>>>
>>> I see this in the log.
>>>
>>> support.SimpAnnotationMethodMessageHandler Handling message,
>>> lookupDestination=/start/MY_FILE
>>>
>>> support.SimpAnnotationMethodMessageHandler No matching method found
>>>
>>>
>>> On Friday, August 1, 2014 3:17:33 PM UTC-4, zyro wrote:
>>>
>>>      hi,
>>>
>>>      check
>>>
>>>
>>> http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referenc
>>> e/htmlsingle/#websocket-stomp-handle-annotations
>>>
>>> <http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referen
>>> ce/htmlsingle/#websocket-stomp-handle-annotations>
>>>
>>>
>>>      sth. like this should work:
>>>
>>>      @MessageMapping("/start/{file}")
>>>      protected void startProcess(@DestinationVariable String file){
>>>            //do somethig with the file...
>>>      }
>>>
>>>      do not hesitate to post back if you are facing difficulties.
>>>
>>>      zyro
>>>
>>>      -------- Original Message  --------
>>>      Subject: @MessageMapping with Grails spring-websocket plugin
>>>      From: vgoud <[hidden email] <javascript:>>
>>>      To: [hidden email] <javascript:>
>>>      Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)
>>>
>>>       > I am a Grails newbie and working on getting WebSockets working
>>> in an
>>>       > application. I got most of it working except I couldn't figure
>>>      out how
>>>       > to pass parameters to the methods annotated with @MessageMapping.
>>>       >
>>>       > This works:
>>>       >
>>>       > <!-- language: lang-groovy -->
>>>       > `class MyController{
>>>       >      @MessageMapping(value="/start")
>>>       >      protected void startProcess(){ }
>>>       > }
>>>       > `
>>>       >
>>>       > What I need something like this to work:
>>>       >
>>>       > <!-- language: lang-java -->
>>>       > `
>>>       >       @MessageMapping(value="/start/{file}")
>>>       >       protected void startProcess(){
>>>       >           String file = params.file
>>>       >           //do somethig with the file...
>>>       >       }
>>>       > `
>>>       > But it doesn't work. I have tried playing with
>>> UrlMappings.groovy,
>>>       > @PathVariable. I am pretty sure I am missing something simple.
>>>      Any pointers?
>>>       >
>>>       > --
>>>       > You received this message because you are subscribed to the
>>> Google
>>>       > Groups "Grails Dev Discuss" group.
>>>       > To unsubscribe from this group and stop receiving emails from it,
>>>      send
>>>       > an email to [hidden email]
>>>      <javascript:>
>>>       > <mailto:[hidden email]
>>>      <javascript:>>.
>>>       > To post to this group, send email to
>>>      [hidden email] <javascript:>
>>>       > <mailto:[hidden email] <javascript:>>.
>>>       > To view this discussion on the web visit
>>>       >
>>>
>>> https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-9
>>> 9bd-b03dc2c55ddd%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>> 99bd-b03dc2c55ddd%40googlegroups.com>
>>>
>>>       >
>>>
>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>> 99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer
>>>
>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>> 99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>>
>>> .
>>>
>>>       > For more options, visit https://groups.google.com/d/optout
>>>      <https://groups.google.com/d/optout>.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Grails Dev Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [hidden email]
>>> <mailto:[hidden email]>.
>>> To post to this group, send email to [hidden email]
>>> <mailto:[hidden email]>.
>>> To view this discussion on the web visit
>>>
>>> https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8
>>> 592-40832a026625%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-
>>> 8592-40832a026625%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Grails Dev Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/grails-dev-discuss/53E11493.9020509%40zy
>> ro.net.
>> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/53E277AC.3080409%40zyro.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @MessageMapping with Grails spring-websocket plugin

zyro
filename meaning your mentioned absolute path.

-------- Original Message  --------
Subject: Re: @MessageMapping with Grails spring-websocket plugin
From: zyro <[hidden email]>
To: [hidden email]
Date: Wed, 06 Aug 2014 20:45:00 +0200

> yea if its only about the filename, i would opt for using the payload
> itself.
>
> @MessageMapping("/start")
> protected void start(String file) {
>      println file
> }
>
> just note that although it is just a string, it needs to be valid json
> for the transport, i.e. use JSON.stringify(fileName) when sending from
> javascript.
>
> zyro
>
> -------- Original Message  --------
> Subject: Re: @MessageMapping with Grails spring-websocket plugin
> From: Goud, Venkat <[hidden email]>
> To: [hidden email]
> <[hidden email]>
> Date: Wed, 6 Aug 2014 18:09:40 +0000
>
>> It is an absolute path to a file. After playing around with regular
>> expressions without much luck, I am finally using this approach:
>>
>> //file is URLencoded
>> @MessageMapping("/start?f={file}²)
>> protected def start(@DestinationVariable String file) {
>>
>>     logFile = URLDecoder.decode(file, "UTF-8²);
>> }
>>
>> I guess I could have put the file name in the payload and use it without
>> the encode and decode.
>>
>>
>>
>> On 8/5/14, 1:29 PM, "zyro" <[hidden email]> wrote:
>>
>>> may i ask what type the actual payload of your message is?
>>> i think there are a few more options to achieve passing in that filename
>>> which do not rely on dynamic destination mapping, e.g.
>>> - the filename as the payload itself
>>> - the filename as a part of a json object thats the payload
>>> - the filename as a message header
>>>
>>> zyro
>>>
>>> -------- Original Message  --------
>>> Subject: Re: @MessageMapping with Grails spring-websocket plugin
>>> From: vgoud <[hidden email]>
>>> To: [hidden email]
>>> Date: Mon, 4 Aug 2014 14:53:18 -0700 (pdt)
>>>
>>>> Thank you. That works, most of the time..
>>>> I am noticing a strange behavior where it seems to stop and start
>>>> working randomly. I have spent a whole day trying to isolate the
>>>> problem
>>>> but no luck. It's been very frustrating.
>>>>
>>>>
>>>> I see this in the log.
>>>>
>>>> support.SimpAnnotationMethodMessageHandler Handling message,
>>>> lookupDestination=/start/MY_FILE
>>>>
>>>> support.SimpAnnotationMethodMessageHandler No matching method found
>>>>
>>>>
>>>> On Friday, August 1, 2014 3:17:33 PM UTC-4, zyro wrote:
>>>>
>>>>      hi,
>>>>
>>>>      check
>>>>
>>>>
>>>> http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referenc
>>>>
>>>> e/htmlsingle/#websocket-stomp-handle-annotations
>>>>
>>>> <http://docs.spring.io/spring/docs/4.0.6.RELEASE/spring-framework-referen
>>>>
>>>> ce/htmlsingle/#websocket-stomp-handle-annotations>
>>>>
>>>>
>>>>      sth. like this should work:
>>>>
>>>>      @MessageMapping("/start/{file}")
>>>>      protected void startProcess(@DestinationVariable String file){
>>>>            //do somethig with the file...
>>>>      }
>>>>
>>>>      do not hesitate to post back if you are facing difficulties.
>>>>
>>>>      zyro
>>>>
>>>>      -------- Original Message  --------
>>>>      Subject: @MessageMapping with Grails spring-websocket plugin
>>>>      From: vgoud <[hidden email] <javascript:>>
>>>>      To: [hidden email] <javascript:>
>>>>      Date: Fri, 1 Aug 2014 12:07:39 -0700 (pdt)
>>>>
>>>>       > I am a Grails newbie and working on getting WebSockets working
>>>> in an
>>>>       > application. I got most of it working except I couldn't figure
>>>>      out how
>>>>       > to pass parameters to the methods annotated with
>>>> @MessageMapping.
>>>>       >
>>>>       > This works:
>>>>       >
>>>>       > <!-- language: lang-groovy -->
>>>>       > `class MyController{
>>>>       >      @MessageMapping(value="/start")
>>>>       >      protected void startProcess(){ }
>>>>       > }
>>>>       > `
>>>>       >
>>>>       > What I need something like this to work:
>>>>       >
>>>>       > <!-- language: lang-java -->
>>>>       > `
>>>>       >       @MessageMapping(value="/start/{file}")
>>>>       >       protected void startProcess(){
>>>>       >           String file = params.file
>>>>       >           //do somethig with the file...
>>>>       >       }
>>>>       > `
>>>>       > But it doesn't work. I have tried playing with
>>>> UrlMappings.groovy,
>>>>       > @PathVariable. I am pretty sure I am missing something simple.
>>>>      Any pointers?
>>>>       >
>>>>       > --
>>>>       > You received this message because you are subscribed to the
>>>> Google
>>>>       > Groups "Grails Dev Discuss" group.
>>>>       > To unsubscribe from this group and stop receiving emails
>>>> from it,
>>>>      send
>>>>       > an email to [hidden email]
>>>>      <javascript:>
>>>>       > <mailto:[hidden email]
>>>>      <javascript:>>.
>>>>       > To post to this group, send email to
>>>>      [hidden email] <javascript:>
>>>>       > <mailto:[hidden email] <javascript:>>.
>>>>       > To view this discussion on the web visit
>>>>       >
>>>>
>>>> https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-9
>>>>
>>>> 9bd-b03dc2c55ddd%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>>>
>>>> 99bd-b03dc2c55ddd%40googlegroups.com>
>>>>
>>>>       >
>>>>
>>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>>>
>>>> 99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>
>>>> <https://groups.google.com/d/msgid/grails-dev-discuss/3e6d0880-f7ef-4aeb-
>>>>
>>>> 99bd-b03dc2c55ddd%40googlegroups.com?utm_medium=email&utm_source=footer>>
>>>>
>>>> .
>>>>
>>>>       > For more options, visit https://groups.google.com/d/optout
>>>>      <https://groups.google.com/d/optout>.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Grails Dev Discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [hidden email]
>>>> <mailto:[hidden email]>.
>>>> To post to this group, send email to
>>>> [hidden email]
>>>> <mailto:[hidden email]>.
>>>> To view this discussion on the web visit
>>>>
>>>> https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-8
>>>>
>>>> 592-40832a026625%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/grails-dev-discuss/8bcac483-beef-40a6-
>>>>
>>>> 8592-40832a026625%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "Grails Dev Discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an
>>> email to [hidden email].
>>> To post to this group, send email to
>>> [hidden email].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/grails-dev-discuss/53E11493.9020509%40zy
>>>
>>> ro.net.
>>> For more options, visit https://groups.google.com/d/optout.
>>

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/53E27800.4060905%40zyro.net.
For more options, visit https://groups.google.com/d/optout.