Esempio n. 1
0
func ReadIncoming(conn net.Conn, queueConn *amqp.Connection) {
	// close connection on exit
	defer conn.Close()

	result, err := ioutil.ReadAll(conn)
	checkError(err)

	err = queue.Publish("incoming", result, queueConn)
	checkError(err)
}
Esempio n. 2
0
// Accepts an input source and attempts to marshall it into a
// protocol buffer, then pushes the message to an AMQP Exchange.
//
// Currently accepts a JSON input but this should change.
func Send(data []byte, connection *amqp.Connection) error {
	pb, err := createProtocolBuffer(data)
	if err != nil {
		return fmt.Errorf("Protocol Buffer Error: %s", err)
	}

	// Send pb to AMQP Exchange
	p_err := queue.Publish("outgoing", pb, connection)
	if p_err != nil {
		return fmt.Errorf("Publishing Error: %s", p_err)
	}

	return nil
}