Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getReceiver example
private
BeanstalkdReceiver
$receiver
;
private
BeanstalkdSender
$sender
;
public
function
__construct
(
Connection
$connection
, SerializerInterface
$serializer
= null
)
{
$this
->connection =
$connection
;
$this
->serializer =
$serializer
??
new
PhpSerializer
(
)
;
}
public
function
get
(
)
: iterable
{
return
$this
->
getReceiver
(
)
->
get
(
)
;
}
public
function
ack
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
ack
(
$envelope
)
;
}
public
function
reject
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
reject
(
$envelope
)
;
}
private
AmqpReceiver
$receiver
;
private
AmqpSender
$sender
;
public
function
__construct
(
Connection
$connection
, SerializerInterface
$serializer
= null
)
{
$this
->connection =
$connection
;
$this
->serializer =
$serializer
??
new
PhpSerializer
(
)
;
}
public
function
get
(
)
: iterable
{
return
$this
->
getReceiver
(
)
->
get
(
)
;
}
public
function
getFromQueues
(
array
$queueNames
)
: iterable
{
return
$this
->
getReceiver
(
)
->
getFromQueues
(
$queueNames
)
;
}
public
function
ack
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
ack
(
$envelope
)
;
}
protected
function
execute
(
InputInterface
$input
, OutputInterface
$output
)
: int
{
$io
=
new
SymfonyStyle
(
$input
,
$output
instanceof ConsoleOutputInterface ?
$output
->
getErrorOutput
(
)
:
$output
)
;
$failureTransportName
=
$input
->
getOption
(
'transport'
)
;
if
(
self::DEFAULT_TRANSPORT_OPTION ===
$failureTransportName
)
{
$failureTransportName
=
$this
->
getGlobalFailureReceiverName
(
)
;
}
$receiver
=
$this
->
getReceiver
(
$failureTransportName
)
;
$shouldForce
=
$input
->
getOption
(
'force'
)
;
$ids
=
(array)
$input
->
getArgument
(
'id'
)
;
$shouldDisplayMessages
=
$input
->
getOption
(
'show-messages'
)
|| 1 === \
count
(
$ids
)
;
$this
->
removeMessages
(
$failureTransportName
,
$ids
,
$receiver
,
$io
,
$shouldForce
,
$shouldDisplayMessages
)
;
return
0;
}
private
function
removeMessages
(
string
$failureTransportName
, array
$ids
, ReceiverInterface
$receiver
, SymfonyStyle
$io
, bool
$shouldForce
, bool
$shouldDisplayMessages
)
: void
{
public
function
complete
(
CompletionInput
$input
, CompletionSuggestions
$suggestions
)
: void
{
if
(
$input
->
mustSuggestOptionValuesFor
(
'transport'
)
)
{
$suggestions
->
suggestValues
(
array_keys
(
$this
->failureTransports->
getProvidedServices
(
)
)
)
;
return
;
}
if
(
$input
->
mustSuggestArgumentValuesFor
(
'id'
)
)
{
$transport
=
$input
->
getOption
(
'transport'
)
;
$transport
= self::DEFAULT_TRANSPORT_OPTION ===
$transport
?
$this
->
getGlobalFailureReceiverName
(
)
:
$transport
;
$receiver
=
$this
->
getReceiver
(
$transport
)
;
if
(
!
$receiver
instanceof ListableReceiverInterface
)
{
return
;
}
$ids
=
[
]
;
foreach
(
$receiver
->
all
(
50
)
as
$envelope
)
{
$ids
[
]
=
$this
->
getMessageId
(
$envelope
)
;
}
$suggestions
->
suggestValues
(
$ids
)
;
$io
=
new
SymfonyStyle
(
$input
,
$output
instanceof ConsoleOutputInterface ?
$output
->
getErrorOutput
(
)
:
$output
)
;
$failureTransportName
=
$input
->
getOption
(
'transport'
)
;
if
(
self::DEFAULT_TRANSPORT_OPTION ===
$failureTransportName
)
{
$this
->
printWarningAvailableFailureTransports
(
$io
,
$this
->
getGlobalFailureReceiverName
(
)
)
;
}
if
(
'' ===
$failureTransportName
|| null ===
$failureTransportName
)
{
$failureTransportName
=
$this
->
interactiveChooseFailureTransport
(
$io
)
;
}
$failureTransportName
= self::DEFAULT_TRANSPORT_OPTION ===
$failureTransportName
?
$this
->
getGlobalFailureReceiverName
(
)
:
$failureTransportName
;
$receiver
=
$this
->
getReceiver
(
$failureTransportName
)
;
$this
->
printPendingMessagesMessage
(
$receiver
,
$io
)
;
if
(
!
$receiver
instanceof ListableReceiverInterface
)
{
throw
new
RuntimeException
(
sprintf
(
'The "%s" receiver does not support listing or showing specific messages.',
$failureTransportName
)
)
;
}
if
(
$input
->
getOption
(
'stats'
)
)
{
$this
->
listMessagesPerClass
(
$failureTransportName
,
$io
,
$input
->
getOption
(
'max'
)
)
;
}
elseif
(
null ===
$id
=
$input
->
getArgument
(
'id'
)
)
{
$this
->
listMessages
(
$failureTransportName
,
$io
,
$input
->
getOption
(
'max'
)
,
$input
->
getOption
(
'class-filter'
)
)
;
}
private
DoctrineReceiver
$receiver
;
private
DoctrineSender
$sender
;
public
function
__construct
(
Connection
$connection
, SerializerInterface
$serializer
)
{
$this
->connection =
$connection
;
$this
->serializer =
$serializer
;
}
public
function
get
(
)
: iterable
{
return
$this
->
getReceiver
(
)
->
get
(
)
;
}
public
function
ack
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
ack
(
$envelope
)
;
}
public
function
reject
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
reject
(
$envelope
)
;
}
public
function
__construct
(
Connection
$connection
, SerializerInterface
$serializer
= null, ReceiverInterface
$receiver
= null, SenderInterface
$sender
= null
)
{
$this
->connection =
$connection
;
$this
->serializer =
$serializer
??
new
PhpSerializer
(
)
;
$this
->receiver =
$receiver
;
$this
->sender =
$sender
;
}
public
function
get
(
)
: iterable
{
return
$this
->
getReceiver
(
)
->
get
(
)
;
}
public
function
ack
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
ack
(
$envelope
)
;
}
public
function
reject
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
reject
(
$envelope
)
;
}
private
RedisReceiver
$receiver
;
private
RedisSender
$sender
;
public
function
__construct
(
Connection
$connection
, SerializerInterface
$serializer
= null
)
{
$this
->connection =
$connection
;
$this
->serializer =
$serializer
??
new
PhpSerializer
(
)
;
}
public
function
get
(
)
: iterable
{
return
$this
->
getReceiver
(
)
->
get
(
)
;
}
public
function
ack
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
ack
(
$envelope
)
;
}
public
function
reject
(
Envelope
$envelope
)
: void
{
$this
->
getReceiver
(
)
->
reject
(
$envelope
)
;
}
$failureTransportName
=
$input
->
getOption
(
'transport'
)
;
if
(
self::DEFAULT_TRANSPORT_OPTION ===
$failureTransportName
)
{
$this
->
printWarningAvailableFailureTransports
(
$io
,
$this
->
getGlobalFailureReceiverName
(
)
)
;
}
if
(
'' ===
$failureTransportName
|| null ===
$failureTransportName
)
{
$failureTransportName
=
$this
->
interactiveChooseFailureTransport
(
$io
)
;
}
$failureTransportName
= self::DEFAULT_TRANSPORT_OPTION ===
$failureTransportName
?
$this
->
getGlobalFailureReceiverName
(
)
:
$failureTransportName
;
$receiver
=
$this
->
getReceiver
(
$failureTransportName
)
;
$this
->
printPendingMessagesMessage
(
$receiver
,
$io
)
;
$io
->
writeln
(
sprintf
(
'To retry all the messages, run <comment>messenger:consume %s</comment>',
$failureTransportName
)
)
;
$shouldForce
=
$input
->
getOption
(
'force'
)
;
$ids
=
$input
->
getArgument
(
'id'
)
;
if
(
0 === \
count
(
$ids
)
)
{
if
(
!
$input
->
isInteractive
(
)
)
{
throw
new
RuntimeException
(
'Message id must be passed when in non-interactive mode.'
)
;
}