Coder Social home page Coder Social logo

support verb headers about stomp HOT 2 CLOSED

go-stomp avatar go-stomp commented on September 16, 2024
support verb headers

from stomp.

Comments (2)

ebenoist avatar ebenoist commented on September 16, 2024

@alaska

I'm currently having a similar-ish issue, I've been using the following locally as a POC. Would this solve your issue as well?

// Subscribe creates a subscription on the STOMP server.
// The subscription has a destination, and messages sent to that destination
// will be received by this subscription. A subscription has a channel
// on which the calling program can receive messages.
func (c *Conn) Subscribe(destination string, ack AckMode) (*Subscription, error) {
    return c.SubscribeWithHeaders(destination, ack, NewHeader())
}

func (c *Conn) SubscribeWithHeaders(destination string, ack AckMode, userDefined *Header) (*Subscription, error) {
    ch := make(chan *Frame)
    headers := userDefined.Clone()

    if _, ok := headers.Contains(frame.Id); !ok {
        headers.Add(frame.Id, allocateId())
    }

    headers.Add(frame.Destination, destination)
    headers.Add(frame.Ack, ack.String())

    f := NewFrame(frame.SUBSCRIBE)
    f.Header = headers

    request := writeRequest{Frame: f, C: ch}

    sub := &Subscription{
        id:          headers.Get(frame.Id),
        destination: destination,
        conn:        c,
        ackMode:     ack,
        C:           make(chan *Message, 16),
    }
    go sub.readLoop(ch)

    c.writeCh <- request
    return sub, nil
}

from stomp.

jjeffery avatar jjeffery commented on September 16, 2024

I have been working on a new version of the API which solves this problem. Unfortunately the new API has some breaking changes from the old API, so this may be a problem for you.

The new API is documented at http://godoc.org/github.com/go-stomp/stomp -- there is now an ability to send custom header entries when you subscribe.

sub, err := conn.Subscribe("/queue/name", stomp.AckClient,
                        stomp.SuscribeOpt.Header("activemq.prefetchsize", "10))

if err != nil {
    return err
}

// and so on ..

from stomp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.