def republish(producer, message, exchange=None, routing_key=None, remove_props=[u'application_headers', u'content_type', u'content_encoding', u'headers']):
 body = ensure_bytes(message.body)
 (info, headers, props) = (message.delivery_info, message.headers, message.properties)
 exchange = (info[u'exchange'] if (exchange is None) else exchange)
 routing_key = (info[u'routing_key'] if (routing_key is None) else routing_key)
 (ctype, enc) = (message.content_type, message.content_encoding)
 compression = headers.pop(u'compression', None)
 for key in remove_props:
  props.pop(key, None)
 producer.publish(ensure_bytes(body), exchange=exchange, routing_key=routing_key, compression=compression, headers=headers, content_type=ctype, content_encoding=enc, **props)

def republish ( producer , message , exchange = None , routing_key = None , remove_props = [ u'application_headers' , u'content_type' , u'content_encoding' , u'headers' ] ) : body = ensure_bytes ( message . body ) ( info , headers , props ) = ( message . delivery_info , message . headers , message . properties ) exchange = ( info [ u'exchange' ] if ( exchange is None ) else exchange ) routing_key = ( info [ u'routing_key' ] if ( routing_key is None ) else routing_key ) ( ctype , enc ) = ( message . content_type , message . content_encoding ) compression = headers . pop ( u'compression' , None ) for key in remove_props : props . pop ( key , None ) producer . publish ( ensure_bytes ( body ) , exchange = exchange , routing_key = routing_key , compression = compression , headers = headers , content_type = ctype , content_encoding = enc , ** props )
republish message .