When connecting to an service provided using anycast, I am experiencing different behaviour depending on whether the request is made using TCP or UDP.
With TCP, the request is made to address A, and the subsequent response also comes from A.
With UDP however, while the request is made to A, the response comes from address B.
Is this correct behaviour, or should the UDP response come from the same address it's sent to?
What you're seeing here may be more a factor of OS default source address selection semantics then an anycast issue specifically, although an anycasted setup will expose the problem more quickly.
On systems with multiple IPs (which is almost always the case for anycast uses), outgoing connections will originate from the machine's primary IP. Since TCP uses connections, there's a stronger association between the destination address of an incoming packet and the origin address of the reply; UDP doesn't have this as much.
For your UDP-based anycasted app, you will probably want to look on the server side for a setting to chose the interface to bind to, and possibly an additional setting for the address to use for outgoing connections.